public boolean setDecorViewImage(Activity activity){ try { //整个手机屏幕的视图 View view = activity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bitmap = 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(bitmap, 0, statusBarHeight, width, height - statusBarHeight); savePic(b,activity); // View view = activity.getWindow().getDecorView(); // view.setDrawingCacheEnabled(true); // vie
android 截屏+保存图片+权限
最新推荐文章于 2025-06-05 13:05:36 发布