android实现截屏
16lz
2021-01-23
private Bitmap shot(Activity activity) { //View是你需要截图的View View view = activity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap b1 = view.getDrawingCache(); // 获取状态栏高度 / Rect frame = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; Log.i("TAG", "" + statusBarHeight); // 获取屏幕长和高 int width = activity.getWindowManager().getDefaultDisplay().getWidth(); int height = activity.getWindowManager().getDefaultDisplay().getHeight(); // 去掉标题栏Bitmap b = Bitmap.createBitmap(b1, 0, 25, 320, 455); Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height - statusBarHeight);view.destroyDrawingCache(); return b; }
更多相关文章
- android获取手机屏幕的宽度及高度
- Android code cut 1 --圆形在屏幕撞墙弹回
- Android WebView 图片自适应屏幕宽度
- 调用android自带的截图工具进行截图
- android的全屏和屏幕高宽的获取
- Android 下保持屏幕常亮
- Android获取屏幕宽和高
- Android 获取屏幕的分辨率
- Android 修改系统屏幕亮度及监听