分享

android中include标签的使用

 Babylly 2011-12-08
  1. <CheckBox android:id="@+id/hideAcc" android:layout_width="wrap_content" android:layout_height="wrap_content"/>  
  2.                         <TextView android:id="@+id/commPwd" android:text="@string/ycUserAcc" style="@style/StyleTextInfo1" mce_style="@style/StyleTextInfo1"/>  
  3.                     </LinearLayout>         
  4.                 </LinearLayout>  
  5.                   
  6.             <LinearLayout android:id="@+id/linearLayoutTab1" android:layout_height="wrap_content"   
  7.                     android:layout_width="fill_parent" android:orientation="horizontal">  
  8.               
  9.                     <LinearLayout android:layout_width="220px" android:layout_height="wrap_content" android:orientation="horizontal"   
  10.                         android:gravity="center">  
  11.                               
  12.                                 <Button android:id="@+id/confirmexch" android:gravity="center" android:layout_width="wrap_content"    
  13.                                     android:layout_height="50px" android:textSize="22dp" android:text="@string/login" android:layout_weight="1"  
  14.                                     android:focusable="false" android:textColor="@color/white" android:background="@drawable/buttonl"/>  
  15.                     </LinearLayout>  
  16.                   
  17.                     <LinearLayout android:id="@+id/linearLayoutTab" android:layout_height="wrap_content"   
  18.                         android:layout_width="fill_parent" android:gravity="center">  
  19.                         <ImageView android:layout_width="wrap_content" android:layout_height="50px" android:id="@+id/myImage"/>  
  20.                     </LinearLayout>  
  21.         </LinearLayout>  
  22.     </LinearLayout>  
  23.     </LinearLayout>  
  24. </ScrollView>  

 

app_bottom.xml:

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout android:id="@+id/appbottom" android:orientation="vertical" android:layout_width="fill_parent"   
  3.         android:layout_height="wrap_content" android:layout_alignParentBottom="true"  
  4.         xmlns:android="http://schemas./apk/res/android">  
  5.           
  6.     <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"   
  7.         android:layout_height="wrap_content" android:background="@drawable/light">  
  8.         <ImageView  android:id="@+id/about" android:layout_width="30px" android:layout_height="wrap_content" android:src="@drawable/ttt"  
  9.                 android:layout_alignParentLeft="true"/>  
  10.         <TextView android:id="@+id/light" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="@color/black"/>  
  11.     </LinearLayout>  
  12.       
  13.     <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent"   
  14.         android:layout_height="wrap_content" android:background="@drawable/mainmenu">  
  15.         <Button android:id="@+id/quotButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"  
  16.             android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>  
  17.               
  18.         <Button android:id="@+id/entrustButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"  
  19.             android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>  
  20.         <Button android:id="@+id/queryButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"  
  21.             android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>  
  22.               
  23.         <Button android:id="@+id/yinZhengButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"  
  24.             android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>  
  25.               
  26.         <Button android:id="@+id/recordButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"  
  27.             android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>  
  28.               
  29.         <Button android:id="@+id/logoutButton" android:layout_weight="1" android:layout_width="52px" android:layout_height="wrap_content"  
  30.             android:textColor="@color/white" android:text="" android:background="@drawable/button1"/>  
  31.     </LinearLayout>  
  32. </LinearLayout>  

 

tradelogin_portrait.xml:

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" style="@style/StyleLayoutMain" mce_style="@style/StyleLayoutMain"  
  3.     xmlns:android="http://schemas./apk/res/android">  
  4.       
  5.     <!-- include标签内不能设置RelativeLayout属性,如android:layout_alignParentBottom,因为不起作用 -->  
  6.     <!-- include标签内设置id属性后(android:id),其引用的布局layout内的id属性就不起作用了,怀疑是其引用的layout外层包裹了一层include标签   
  7.         或者是覆盖了其内的属性id-->  
  8.     <!-- 如果没有include标签,所有布局代码都写在一个xml文件中,界面会显得很冗余,可读性很差。而且界面加载的时候是按照顺序加载的,前面的布局不能  
  9.         调用其后面的布局id。而采用include后,一个include中可以引用其后的include中的布局id属性 -->  
  10.     <include android:id="@id/titleLayout" layout="@layout/app_title" />  
  11.   
  12.     <include layout="@layout/app_tradelogin"/>  
  13.           
  14.     <include layout="@layout/app_bottom"/>  
  15.       
  16. </RelativeLayout>  

 

效果如下:

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约