Android下免Root权限截屏
16lz
2021-01-23
/** * 返回的 bitmap就是屏幕的内容 */private static Bitmap takeScreenShot(Activity activity) {View view = activity.getWindow().getDecorView();//Enables or disables the drawing cacheview.setDrawingCacheEnabled(true);//will draw the view in a bitmapview.buildDrawingCache();Bitmap bitmap = view.getDrawingCache();Rect frame = new Rect();activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);int statusBarHeight = frame.top;int width = activity.getWindowManager().getDefaultDisplay().getWidth();int height = activity.getWindowManager().getDefaultDisplay().getHeight();// 去掉标题栏Bitmap b = Bitmap.createBitmap(bitmap, 0, statusBarHeight, width,height - statusBarHeight);view.destroyDrawingCache();return b;}
更多相关文章
- 【Android】【基础】获取屏幕宽高
- Android手动切换屏幕方向
- Android获取屏幕尺寸
- android 保持屏幕长亮及解锁的方法
- Android 获取屏幕尺寸实例代码
- Android获取屏幕宽高的方法
- android > 读取http html 内容