Android View buffer mechanism and Android View BUFFER MECHANISM

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.