解析android中include标签的使用

本篇文章是对android中include标签的使用进行了详细的分析介绍,需要的朋友参考下

在一个项目中我们可能会需要用到相同的布局设计,如果都写在一个xml文件中,代码显得很冗余,并且可读性也很差,所以我们可以把相同布局的代码单独写成一个模块,然后用到的时候可以通过 标签来重用layout代码。
app_title.xml:
复制代码 代码如下:


   android:background="@drawable/bt" xmlns:android="http://schemas.android.com/apk/res/android">

     android:layout_width="wrap_content" android:layout_centerInParent="true" android:layout_height="wrap_content"/>  
  

app_tradelogin.xml:
复制代码 代码如下:



  android:layout_height="fill_parent" android:layout_centerInParent="true" xmlns:android="http://schemas.android.com/apk/res/android">
   android:layout_height="wrap_content" android:paddingLeft="10px" android:paddingTop="6px" android:paddingRight="10px" >
  
       android:layout_height="fill_parent" android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" android:stretchColumns="1">
    
    
     
     
     

    


    
     
     
    


    
     
     
    


    
     
     
    


    
     
     
    


    
     
     
    

   

  


  

         android:layout_width="fill_parent" android:orientation="horizontal">

           android:layout_width="fill_parent" android:orientation="horizontal" android:layout_weight="1">
      
      
     
 
           android:layout_width="fill_parent" android:orientation="horizontal" android:layout_weight="1">

      
      
     
  
    


        android:layout_width="fill_parent" android:orientation="horizontal">

           android:gravity="center">

              

app_bottom.xml:
复制代码 代码如下:


  android:layout_height="wrap_content" android:layout_alignParentBottom="true"
  xmlns:android="http://schemas.android.com/apk/res/android">

   android:layout_height="wrap_content" android:background="@drawable/light">
      android:layout_alignParentLeft="true"/>
  
 


   android:layout_height="wrap_content" android:background="@drawable/mainmenu">
  

tradelogin_portrait.xml:
复制代码 代码如下:


 xmlns:android="http://schemas.android.com/apk/res/android">

 
 
 
 
 

 



效果如下:

以上就是解析android中include标签的使用的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 移动