Use of the Android merge tag

Source: Internet
Author: User

<merge xmlns:android="http://schemas.android.com/apk/res/android"> <ToggleButton Android:id="@+id/togglebutton1"Android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:text="ToggleButton"/> <TextView android:layout_width="wrap_content"Android:layout_height="wrap_content"Android:layout_marginbottom="20dip"android:layout_gravity="Center_horizontal|bottom"android:padding="12dip"Android:background="#AA000000"Android:textcolor="#ffffffff"Android:text="Golden Gate"/> </merge>

1.merge layouts are similar to framelayout, with the same effect. The merge layout can only be included with the <include> tag. or used by Activity.setcontentview.

When Layoutinflater encounters a <include> that can be included with another layout, and no longer generates viewgroup containers, this element is particularly useful for this tag, it skips it and adds elements from the <merge/> to the <merge/> In the parent element. The reason that activity can be used directly is that the parent element of the activity is Framelayout

2 merge can be included with <include> in other layout, and no more viewgroup containers are generated. That is, it reduces the first layer of layout to optimize layout.

Limit:

<merge/> can only be used as the root tag of an XML layout
· When you inflate a layout file that begins with <merge/>, you must specify a parent ViewGroup, and you must set Attachtoroot to True (see inflate (int, android.view.ViewGroup, Boolean) method).

Use of the Android merge tag

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.