/**
* 获取当前屏幕截图,不包含状态栏
* @param activity
* @return bp
*/
public static Bitmap snapShotWithoutStatusBar(Activity activity) {
View view = activity.getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bmp = view.getDrawingCache();
if (bmp == null) {
return null;
}
Rect frame = new Rect();
activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
Bitmap bp = Bitmap.createBitmap(bmp, 0, statusBarHeight, bmp.getWidth(), bmp.getHeight() - statusBarHeight);
view.destroyDrawingCache();
view.setDrawingCacheEnabled(false);
return bp;
}
Bitmap map = ScreenUtil.snapShotWithoutStatusBar(MainActivity.this);
img.setImageBitmap(map);