The buffering mechanism of Android view

Source: Internet
Author: User

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

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.