控件截图Cache

一共有4个接口

void  setDrawingCacheEnabled(boolean flag),

Bitmap  getDrawingCache(boolean autoScale),

void  buildDrawingCache(boolean autoScale),

void  destroyDrawingCache()

1.开启cache

layout.setDrawingCacheEnabled(true);

2.获得cache图片 。

(buildDrawingCache方法可以不用调用,因为调用getDrawingCache方法时,若果 cache没有建立,系统会自动调用buildDrawingCache方法生成cache。

bitmap=layout.getDrawingCache();

3.销毁cache 

(如果不销毁cache,它始终保存一张图片不会变。另外,销毁方式有两个方法

  layout.destroyDrawingCache();
 //layout.setDrawingCacheEnabled(false);
原文地址:https://www.cnblogs.com/lyxin/p/5909746.html