[Android] Android layout optimization <include/>

Source: Internet
Author: User

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

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

> Extracts reusable components and uses them through the include tag.

Role: Extract common components into a single XML file, and then use the include tag to import a common layout.

Effect: Improve UI authoring and reuse efficiency, and ensure the UI layout is more structured and easy to maintain.

Eg:<include layout= "@layout/common_title"/>

Common_title.xml<?xml version="1.0"encoding="Utf-8"? ><relativelayout xmlns:android="http://schemas.android.com/apk/res/android"Android:layout_width="match_parent"Android:layout_height="wrap_content"Android:background="#000000"Android:paddingbottom="10DP"Android:paddingtop="10DP"> <TextView Android:id="@+id/re"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:layout_alignparentleft="true"android:layout_centervertical="true"Android:layout_marginleft="10DP"Android:text="return"Android:textcolor="#ffffff"android:textsize="14SP"/> <TextView Android:id="@+id/title"Android:layout_width="wrap_content"Android:layout_height="wrap_content"android:layout_centerinparent="true"Android:text="Layout Optimization"Android:textcolor="#ffffff"android:textsize="18SP"/> <TextView Android:id="@+id/fun"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:layout_alignparentright="true"android:layout_centervertical="true"Android:layout_marginright="10DP"Android:text="function"Android:textcolor="#ffffff"android:textsize="14SP"/></relativelayout>--------------------------------------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"/></linearlayout>

[Android] Android layout optimization <include/>

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.