Android下免Root权限截屏
2018-07-20 来源:open-open
/**
* 返回的 bitmap就是屏幕的内容
*/
private static Bitmap takeScreenShot(Activity activity) {
View view = activity.getWindow().getDecorView();
// Enables or disables the drawing cache
view.setDrawingCacheEnabled(true);
// will draw the view in a bitmap
view.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;
}
标签: isp
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
下一篇:php去除html标签代码
最新资讯
热门推荐