Android Chinese api-<merge/> tags

Source: Internet
Author: User


Use <merge/> tag


This <merge/> tag helps us eliminate redundant view Groups when including a layout, for example, your main layout file is a vertical linearlayout.

<linearyout xmlns:android = http://schemas.android.com/apk/res/android

Android:layout_width= "Match_parent"

android:layout_height= "Match_parent"

android:orientation = "vertical" >


<button
Android:layout_width="Fill_parent"
Android:layout_height="Wrap_content"
Android:text="Text"/>

<button
Android:layout_width="Fill_parent"
Android:layout_height="Wrap_content"
Android:text="Text"/>

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


</linearyout>


at this point: analyze the following Ok_no_pannel.xml , the wording of the document:

<linearyout xmlns:android = http://schemas.android.com/apk/res/android

Android:layout_width= "Match_parent"

android:layout_height= "Match_parent"

android:orientation = "vertical" >

   <button   android:layout_width = "Fill_parent"    android:layout_height = "Wrap_content"    android:text = "@string/add"/>     <button   android:layout_width = "Fill_parent"    android:layout_height = "Wrap_content"    android:text = "@string/delete"/>  </linearyout >

The wording of the above documents, you will find that once include execution is done and you will find that there is a layer of LinearLayout It's useless to pass Merge label, we can easily solve this problem.

  <merge  xmlns:android="http://schemas.android.com/apk/res/android ">    <button   android:layout_width = "Fill_parent"    android:layout_height = "Wrap_content"    android:text = "@string/add"/>     <button   android:layout_width = "Fill_parent"    android:layout_height = "Wrap_content"    android:text = "@string/delete"/>  </merge>

Now , when you pass include tag to embed a layout file in another layout file, the system ignores Merge label, directly add two Button element is placed in the layout file instead of the include the location of the label.


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-<merge/> tags

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.