[Android] Android Layout Optimization Merge

Source: Internet
Author: User

Reprint please indicate: reproduced in http://www.cnblogs.com/Liuyt-61/p/6602915.html

-----------------------------------------------------------------

> Merge UI layouts with merge

What it does: Merge UI layouts that reduce the nesting level of the UI layout

Scene (1): The layout root node is framelayout and does not need to set properties such as background or padding, which can be replaced by the merge.

Scene (2): When a layout is used as a sub-layout by another layout include, use merge as the top node of the layout, which is automatically ignored when the top node is introduced.

Common_progress.xml<?xml version="1.0"encoding="Utf-8"? ><merge xmlns:android="http://schemas.android.com/apk/res/android"Android:layout_width="match_parent"Android:layout_height="match_parent"android:orientation="Vertical"> <ProgressBar android:layout_width="wrap_content"Android:layout_height="wrap_content"android:layout_gravity="Center"/> <TextView Android:id="@+id/textview"Android:layout_width="wrap_content"Android:layout_height="wrap_content"android:layout_gravity="Center"Android:text="Please later"/></merge>-------------------------------------------------Main.xml<?xml version="1.0"encoding="Utf-8"? ><linearlayout xmlns:android="http://schemas.android.com/apk/res/android"Android:layout_width="match_parent"Android:layout_height="match_parent"android:orientation="Vertical"> <include layout="@layout/common_title"/> <framelayout android:layout_width="match_parent"Android:layout_height="wrap_content"> <TextView Android:id="@+id/textview"Android:layout_width="match_parent"Android:layout_height="wrap_content"Android:text="Body Content"android:textsize="16sp"/> <include layout="@layout/common_progress"/> </FrameLayout></LinearLayout>

[Android] Android Layout Optimization Merge

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.