Android Chinese Api-include tags

Source: Internet
Author: User

While Android offers a variety of reusable lightweight interactive elements such as TextView, you may also want to reuse some of the relatively large, special layout XML. To effectively reuse layout files, you can use include tags and merge tags, which are special layout files that are embedded in the current layout.

Reusable layouts are particularly powerful. For example, a button panel containing the OK and cancel, or a custom progress bar (ProgressBar) accompanying the copy. This means that in an application, a common part of a complex layout can be extracted, managed independently, and then embedded in an include where it is needed. So, you can also create a separate UI component by customizing the view, which is easier to use than the Include method.

Create a re-usable Layout

Create a reusable layout file. (titlebar.xml)

<framelayoutxmlns:android="Http://schemas.android.com/apk/res/android"
Android:layout_width="Match_parent"
Android:layout_height="Wrap_content"
Android:background="@color/titlebar_bg">

<imageview Android:layout_width="Wrap_content"
Android:layout_height="Wrap_content"
android:src="@drawable/gafricalogo"/>
</FrameLayout>

This root view should be accurate so that the file can be displayed in any of the layout files that have been added to it.

Use the <include> Tag

Here ' s the layout file:

<linearlayoutxmlns:android="Http://schemas.android.com/apk/res/android"
android:orientation="Vertical"
Android:layout_width="Match_parent"
Android:layout_height="Match_parent"
Android:background="@color/app_bg"
android:gravity="Center_horizontal">

<include layout="@layout/titlebar"/>

<textview Android:layout_width="Match_parent"
Android:layout_height="Wrap_content"
Android:text="@string/hello"
android:padding="10DP"/>

...

</LinearLayout>

You can also override the ( android:layout_* ) attribute of any reused view's root view in the include tag. For example:

<include  Span style= "COLOR: #882288" >android:id  =   @+ Id/news_title "          android:layout_width " Span style= "COLOR: #666600" >=   "match_parent"           android:layout_height  =  " match_parent "          layout " Span style= "COLOR: #666600" >=   "@layout/title"  />   

However, once you rewrite, you have to rewrite android:layout_height andandroid:layout_width这两个属性,才能让它生效。

The author has a saying: if you need Android Chinese API, please sweep the following QR code, your concern, is my motivation.


Android Chinese Api-include tags

Related Article

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.