Use of view class Drawingcache in Android

Source: Internet
Author: User

reprinted from: Http://blog.sina.com.cn/s/blog_4b93170a0102e40m.htmlthe 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) The setchildrendrawingcacheenabled method allows all sub-view in the ViewGroup to open the cache; Setchildrendrawnwithcacheenabled allows you to draw a child view by using its cache if the child view opens the cache, 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).

Use of view class Drawingcache in Android

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.