android中的佈局--嵌套佈局

在同一個Activity中要實現多種不同的佈局類型或者同種佈局類型的不同方式,就需要用到嵌套的方式來實現。

例子程序實現:
(1)整個Activity最外層採用垂直方向的LinearLayout線性佈局。
(2)套用兩個LinearLayout線性佈局,上面的是水平方向的,下面的是垂直方向的。
(3)上下的LinearLayout內各放置4個空間

[java] view plaincopy
  1. <span style="color:#339933"></span><pre name="code" class="html"><?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7.     <LinearLayout   
  8.         android:orientation="horizontal"  
  9.         android:layout_width="fill_parent"  
  10.         android:layout_height="fill_parent"  
  11.         android:layout_weight="1">  
  12.         <TextView  
  13.           android:text="red"  
  14.           android:gravity="center_horizontal"  
  15.           android:background="#aa0000"  
  16.           android:layout_width="wrap_content"  
  17.           android:layout_height="fill_parent"  
  18.           android:layout_weight="1"/>  
  19.       <TextView  
  20.           ...../>  
  21.       <TextView  
  22.           ...../>  
  23.       <TextView  
  24.           ...../>  
  25.     </LinearLayout>  
  26.    
  27.    
  28.     <LinearLayout   
  29.         android:orientation="vertical"  
  30.         android:layout_width="fill_parent"  
  31.         android:layout_height="fill_parent"  
  32.         android:layout_weight="1">  
  33.     <TextView  
  34.         ...../>  
  35.     <TextView  
  36.         ...../>  
  37.     <TextView  
  38.         ...../>  
  39.     <TextView  
  40.         ...../>  
  41.     </LinearLayout>  
  42. </LinearLayout></pre><span style="color:rgb(80,67,61); font-family:Arial,Helvetica,Georgia,sans-serif; font-size:14px; line-height:25px">其實就是按照設計思路中的佈局要求,直接在上層佈局中嵌套使用新的佈局即可。</span><br><br>  



文章轉自:http://blog.csdn.net/wangchenggong88/article/details/6655235


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章