android TextureView destroyDrawingCache(关闭Camera时,清除预览画面上的卡的最后一帧画面)
2017-10-18 11:51
1776 查看
View组件显示的内容可以通过cache机制保存为bitmap, 主要有以下方法:
void setDrawingCacheEnabled(boolean flag),
Bitmap getDrawingCache(boolean autoScale),
void buildDrawingCache(boolean autoScale),
void destroyDrawingCache()
我们要获取cache首先要通过setDrawingCacheEnable方法开启cache,然后再调用getDrawingCache方法就可以获得view的cache图片了。
buildDrawingCache方法可以不用调用,因为调用getDrawingCache方法时,若果cache没有建立,系统会自动调用buildDrawingCache方法生成cache。
若想更新cache, 必须要调用destoryDrawingCache方法把旧的cache销毁,才能建立新的。
当调用setDrawingCacheEnabled方法设置为false, 系统也会自动把原来的cache销毁。
另外,ViewGroup在绘制子view时,也提供了两个方法
void setChildrenDrawingCacheEnabled(boolean enabled)
setChildrenDrawnWithCacheEnabled(boolean enabled)
setChildrenDrawingCacheEnabled方法可以使viewgroup里所有的子view开启cache;
setChildrenDrawnWithCacheEnabled使在绘制子view时,若该子view开启了cache, 则使用它的cache进行绘制,从而节省绘制时间。
获取cache通常会占用一定的内存,所以通常不需要的时候有必要对其进行清理,通过destroyDrawingCache或setDrawingCacheEnabled(false)实现。
void setDrawingCacheEnabled(boolean flag),
Bitmap getDrawingCache(boolean autoScale),
void buildDrawingCache(boolean autoScale),
void destroyDrawingCache()
我们要获取cache首先要通过setDrawingCacheEnable方法开启cache,然后再调用getDrawingCache方法就可以获得view的cache图片了。
buildDrawingCache方法可以不用调用,因为调用getDrawingCache方法时,若果cache没有建立,系统会自动调用buildDrawingCache方法生成cache。
若想更新cache, 必须要调用destoryDrawingCache方法把旧的cache销毁,才能建立新的。
当调用setDrawingCacheEnabled方法设置为false, 系统也会自动把原来的cache销毁。
另外,ViewGroup在绘制子view时,也提供了两个方法
void setChildrenDrawingCacheEnabled(boolean enabled)
setChildrenDrawnWithCacheEnabled(boolean enabled)
setChildrenDrawingCacheEnabled方法可以使viewgroup里所有的子view开启cache;
setChildrenDrawnWithCacheEnabled使在绘制子view时,若该子view开启了cache, 则使用它的cache进行绘制,从而节省绘制时间。
获取cache通常会占用一定的内存,所以通常不需要的时候有必要对其进行清理,通过destroyDrawingCache或setDrawingCacheEnabled(false)实现。
相关文章推荐
- Android SurfaceTexture和GLSurfaceView做Camera预览
- Android开发使用OpenCv中JavaCameraView预览图左旋90度问题
- Android开发:用getDrawingCache方法获取ImageView中的图像需要注意的问题 本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http:/
- 【转】玩转Android Camera开发(三):国内首发---使用GLSurfaceView预览Camera 基础拍照demo
- 玩转Android Camera开发(一):Surfaceview预览Camera,基础拍照功能完整demo
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- 基于Android TextureView与SurfaceTexture实现相机Camera拍照预览与保存照片
- Android:解决view.getDrawingCache()返回null的问题
- Android解决当调用Camera时预览画面有旋转的问题
- android--Camera完整版--Surfaceview预览Camera,基础拍照功能完整demo
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- Android:解决view.getDrawingCache()返回null的问题
- Android编程中调用Camera时预览画面有旋转问题的解决方法
- android ImageView.getDrawingCache return NULL
- android-destroyDrawingCache
- Android中View转换为Bitmap及getDrawingCache=null的解决方法
- Android应用开发Camera系列(一):SurfaceView实现相机预览demo--新手上路
- 【android学习】imageview通过getDrawingCache获取图像
- Android中View转换为Bitmap及getDrawingCache=null的解决方法