将一个view对象转换为bitmap对象
2016-04-20 12:05
190 查看
private Bitmap getViewBitmap(View addViewContent) {
addViewContent.setDrawingCacheEnabled(true);
addViewContent.measure(
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
addViewContent.layout(0, 0,
addViewContent.getMeasuredWidth(),
addViewContent.getMeasuredHeight());
addViewContent.buildDrawingCache();
Bitmap cacheBitmap = addViewContent.getDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
return bitmap;
}
addViewContent.setDrawingCacheEnabled(true);
addViewContent.measure(
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
addViewContent.layout(0, 0,
addViewContent.getMeasuredWidth(),
addViewContent.getMeasuredHeight());
addViewContent.buildDrawingCache();
Bitmap cacheBitmap = addViewContent.getDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
return bitmap;
}
相关文章推荐
- ORACLE schedule job设置
- iOS证书描述文件说明
- Angular2入门——(1)快速上手
- Android框架知识合集
- 在unity中体验uwebkit插件过程中遇见的几个问题
- 练习2————1004
- 队列Queue 先进先出 栈Stack 先进后出
- Android使用MediaRecorder类进行录制视频
- Android 自定义View合集
- UIBezierPath贝塞尔弧线常用方法记
- iOS 开发--最新版 cocoapods 安装教程
- Java中String的设计原理
- Django之信息聚合
- 142. Linked List Cycle II
- BroadCastResever
- (box-flex) webapp开发信息流的一种方式
- Maven安装
- VB 6.0 使用Sqlite总结知识
- 【hdu5515】【2015ACM/ICPC亚洲区沈阳站】 Game of Flying Circus 题意&题解&代码(C++)
- Android View的事件分发机制探索