The pits that have been trampled during Android development

Source: Internet
Author: User

1) 4.X under ViewGroup not necessarily will pass down requestlayout, when onlayout speed is relatively slow (such as sub-view more complex reasons), the system will jump frame! The view below the sub view may no longer be called Requestlayout's onmeasure and onlayout.

The solution is to optimize the program, reducing the number of layers in the sub-view, such as very complex layouts, using GridLayout and the like, rather than just using linearlayout and framelayout. If the optimization does not solve the problem, consider that the machine performance is also affected by other factors, you can consider the targeted call must refresh the view of the requestlayout. The interface is slower than the interface error is better to accept some.

2) 4.1.1 Under the ImageView picture appears the flower screen. (This issue does not occur in versions 4.2 or more)

Background: In order to control the memory, I have to load the big picture of all the drawable have done a layer of proxy, the underlying use of LRUCache to manage the memory of the image, to avoid loading too many pictures at once memory overflow.

Problem analysis: For the main view open from view, after opening many large images, the main view has shown that the picture has actually been released in memory, the system uses hardware accelerated way to draw when the memory area has been emptied, resulting in a flower screen phenomenon. And the place where I reload the picture is in the Drawable draw method, under 4.1.1, if hardware acceleration does not call this method again, so you need to call View.setlayertype in the corresponding imageview at this point (view.layer_type _hardware, NULL);

More information visible: http://zuiniuwang.blog.51cto.com/3709988/721798/

The pits that have been trampled during Android development

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.