Common tips for Android layout optimization

Source: Internet
Author: User

Android for multiple modules if you want the UI logic of the speech in addition to fragment, there is nothing else to support,

Include,merge,viewstub can only support a common UI, but this generic support cannot contain logic (Java code).

1. Using the Include tag

This tag only initiates the function of repeating a UI XML file, the Android framework does not have any optimizations when parsing, and the only function is to facilitate the management of the role.

When parsing to the include tag, take out the layout file from its Layouts property, parse the layout, and replace the node with the include tag

2. Using the Merge tab

The merge tag, which handles the same features as the include tag (reusing the UI XML file), is a little bit more of an optimization feature,

When parsing to <merge> tags, if a tag below the merge (first layer) is the same as the parent tag, then the child element underneath the tag is added to the parent tag of the merge.

3. Using the Viewstub label

One of the main functions of viewstub is that the framework does not parse the viewstub layout file when it is not visible, a little bit of optimization.

4. Using the Relativelayout label

With this viewgroup you can usually reduce the number of nesting.

Common tips for Android layout optimization

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.