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)方法)。

  • 相关阅读:
    我与计算机简述
    第十五周计应151班第四组排球计分程序
    第十五周排球积分查询程序
    本周总结
    计应1班第4小组第一次产品计划会议
    本周总结
    计应1班第4小组“排球比赛计分程序”的典型用户、创立场景、用户故事
    排球计分规则功能说明书
    我与计算机
    5th 各组作品alpha发布体会
  • 原文地址:https://www.cnblogs.com/zhujiabin/p/4540369.html
Copyright © 2011-2022 走看看