Android View buffer mechanism and Android View BUFFER MECHANISM
The content displayed by the View component can be saved as bitmap through the cache mechanism. The main methods are as follows:
VoidSetDrawingCacheEnabled (boolean flag ),
BitmapGetDrawingCache (boolean autoScale ),
VoidBuildDrawingCache (boolean autoScale ),
VoidDestroyDrawingCache ()
To obtain the cache, you must first enable the cache using the setDrawingCacheEnable method, and then call the getDrawingCache method to obtain the cache image of the view.
You do not need to call the buildDrawingCache method, because when you call the getDrawingCache method, if the cache is not created, the system automatically calls the buildDrawingCache method to generate the cache.
To update the cache, you must call the destoryDrawingCache method to destroy the old cache to create a new one.
When the setDrawingCacheEnabled method is called, the system automatically destroys the original cache.
In addition, ViewGroup provides two methods when drawing a sub-view.
Void setChildrenDrawingCacheENabled (boolean enabled)
SetChildrenDrawnWithCachEEnabled (boolean enabled)
SetChildrenDrawingCacheEThe nabled method enables cache for all sub-views in the viewgroup;
SetChildrenDrawnWithCachEEnabled: when a child view is drawn, if the cache is enabled for the Child view, use its cache to draw the child view, thus saving the Painting time.
Obtaining a cache usually occupies a certain amount of memory, so it is usually unnecessary to clean it, through destroyDrawingCache or setDrawingCacheEnabled (false.