android 截图
来源:互联网 发布:linux 查看java版本 编辑:程序博客网 时间:2024/05/16 07:03
public class ScreenShot { public static Bitmap takeScreenShot(Activity activity) { // View是你须要截图的View View view = activity.getWindow().getDecorView(); int width1 = activity.getWindow().getDecorView().getWidth(); int height1 = activity.getWindow().getDecorView().getHeight(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap b1 = 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(b1, 0, 25, 320, 455); Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height1-statusBarHeight); view.destroyDrawingCache(); return b; } public static void savePic(Bitmap b, String strFileName) { FileOutputStream fos = null; try { fos = new FileOutputStream(strFileName); if (null != fos) { b.compress(Bitmap.CompressFormat.PNG, 90, fos); fos.flush(); fos.close(); } } catch (Exception e) { e.printStackTrace(); } }}
0 0
- Android截图
- android 截图
- Android截图
- android截图
- android截图
- android 截图
- android截图
- Android截图
- Android截图
- android surfaceview截图 系统截图
- 【拍照截图】Android 系统拍照和截图
- Android截图 调用图片照片并截图,相机照相截图
- Android 普通View截图 RecyclerView截图 ScrollView截图分享
- Android截图代码实现
- Android 截图实现(2)
- 使用android模拟器截图
- android 程序截图功能
- 【转】android屏幕截图
- swift class与struct 区别
- hdu2602 Bone Collector(01背包+入门)
- [小技巧] Linux 里快速安装缺少的库
- 完美运动框架(可以改变元素的透明度,宽,高,top,left,字体大小等)
- sql存储过程的加密和解密(适用于SQLSERVER2000存储过程)
- android 截图
- java集合中hashSet与TreeSet学习总结
- Object Property 参数使用
- 面试笔试杂项积累-leetcode 241-245
- Light OJ 1169 - Monkeys on Twin Tower (简单DP)
- Android批量图片加载经典系列——Volley框架实现多布局的新闻列表
- 1031. Hello World for U (20)
- 【第一天】初步接触jQuery
- 为什么Float类型不能直接相等