Android 整个手机屏幕截图和去除状态栏截图
2017-09-13 10:31
369 查看
一、去除状态栏截图
二、整个手机屏幕截图,但状态栏是空白
//整个手机屏幕的视图 View view = getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bitmap = view.getDrawingCache(); // 获取状态栏高度 Rect frame = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; Log.i("TAG", "" + statusBarHeight); // 获取屏幕长和高 int width = getWindowManager().getDefaultDisplay().getWidth(); int height = getWindowManager().getDefaultDisplay().getHeight(); Bitmap b = Bitmap.createBitmap(bitmap, 0, statusBarHeight, width, height - statusBarHeight); //保存图片 FileOutputStream fout = null; try { fout = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/test.png"); } catch (FileNotFoundException e) { e.printStackTrace(); } b.compress(Bitmap.CompressFormat.PNG, 100, fout); //显示截图 mImageView.setImageBitmap(b);
二、整个手机屏幕截图,但状态栏是空白
View view = getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bitmap = view.getDrawingCache(); FileOutputStream fout = null; try { fout = new FileOutputStream(Environment.getExternalStorageDirectory().getAbsolutePath() + "/test.png"); } catch (FileNotFoundException e) { e.printStackTrace(); } bitmap.compress(Bitmap.CompressFormat.PNG, 100, fout); mImageView.setImageBitmap(bitmap);
相关文章推荐
- android实现屏幕截图并保存(去除状态栏)
- android常见的屏幕工具,获取屏幕宽高,状态栏高,手机截屏(包括状态栏和不包括状态栏)
- Android获取手机屏幕宽高、状态栏高度以及字符串宽高信息的方法
- 去除状态栏让Activity充满整个屏幕
- PC端获取Android手机当前屏幕截图的方法
- 通过Python连接手机,并截图手机屏幕保存到电脑(android)
- [置顶] 新修改ADB,支持Android 4.2 系统 ,全部中文命令,手机屏幕截图等等
- PC端获取Android手机当前屏幕截图的方法
- Android获取手机屏幕宽高/屏幕状态栏的高度
- Android获取手机屏幕宽高、状态栏高度以及字符串宽高信息的方法
- 关于android手机屏幕密度的实测和状态栏的高度
- android屏幕截图,android怎么截取整个屏幕
- android获得手机屏幕状态栏高度 屏幕高宽度
- Android中 将布局文件/View显示至手机屏幕的 整个过程分析
- Android手机截图代码(针对root设备,可截取任意屏幕)
- Android--获得屏幕高宽,屏幕截图(包括或不包括状态栏)
- Android系统亮屏、锁屏、屏幕解锁事件(解决部分手机亮屏后未解锁即进入resume状态)