the content displayed by the view component can be saved as bitmap through the cache mechanism, mainly in the following ways:
void setdrawingcacheenabled (Boolean flag),
Bitmap getdrawingcache (boolean Autoscale),
void Builddrawingcache (boolean Autoscale),
void destroydrawingcache ()
we need to get the cache first by using the Setdrawingcacheenable method to open the cache and then call the Getdrawingcache method to get the cache image of the view.
the Builddrawingcache method can not be called, because when the Getdrawingcache method is called, the system automatically calls the Builddrawingcache method to generate the cache if the cache is not established.
To update the cache, you must call the Destorydrawingcache method to destroy the old cache to create a new.
when the call setdrawingcacheenabled method is set to False, the system will automatically destroy the original cache.
In addition, ViewGroup also provides two methods when drawing sub-view
void Setchildrendrawingcacheenabled (Boolean enabled)
Setchildrendrawnwithcacheenabled (Boolean enabled)
theSetchildrendrawingcachee nabled method enables all the sub-view in the ViewGroup to open the cache;
Setchildrendrawnwithcacheenabled makes the child view, if the child view opens the cache, uses its cache to draw, saving drawing time.
getting the cache usually consumes a certain amount of memory, so it is often necessary to clean it up when it is not needed, by Destroydrawingcache or setdrawingcacheenabled (false).
The buffering mechanism of Android view