zoukankan      html  css  js  c++  java
  • android merge 标签的使用

        <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布局 和FrameLayout类似,相同的效果.不同的是 merge布局只能被<include>标签包含. 或者Activity.setContentView所使用.

    当LayoutInflater遇到能被其他layout用<include>包含进去,并不再另外生成ViewGroup容器,本元 素也特别有用这个标签时,它会跳过它,并将<merge />内的元素添加到<merge />的父元素里. Activity能直接使用的原因是Activity的父元素是FrameLayout

    2 merge 能被其他layout用<include>包含进去,并不再另外生成ViewGroup容器.就是说,会减少一层layout到达优化layout的目的

    限制:

             <merge />只能作为XML布局的根标签使用
    ·        当Inflate以<merge />开头的布局文件时,必须指定一个父ViewGroup,并且必须设定attachToRoot为true(参看inflate(int, android.view.ViewGroup, Boolean)方法)。

  • 相关阅读:
    开源控件PullToRefreshGridView的使用(三)
    JS中的运算符 以及变量和输入输出
    HTML中表格
    JS中 事件冒泡与事件捕获
    JS中的循环结构
    UML类图详解
    一步一步生成图片水印
    快速生成缩略图
    ==和Equal()的区别
    屌丝程序人生(下)
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/4540369.html
Copyright © 2011-2022 走看看