What are the optimization measures for the layout in Android?

Source: Internet
Author: User

1. Minimize nesting levels of layouts
You can use the Hierarchyviewer tool provided by the SDK to analyze the view tree to help us discover unused layouts.
2, do not set unnecessary background, avoid excessive drawing
For example, if the parent control sets the background color and the child controls completely overwrite the parent control, then the parent control does not need to set the background.
3. Reuse the same layout code with <include> tags
4. Use <merge> tags to reduce the view hierarchy
There are two main uses of this tag:
1) because the root node of all Activity views is framelayout, so if our custom layout is also
Fragmenlayout, you can use merge instead.
2) when an Include or viewstub tag is imported from an external XML structure, the XML being imported can be used as the root section of the merge
Point, so that when it is embedded in the parent structure, it is good to dissolve the subset it contains into the parent structure without the redundant nodes.
<merge> can only be the root element of an XML layout.
5, through the <ViewStub> implementation of View delay loading

What are the optimization measures for the layout in Android?

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.