Android: LinearLayout布局和其嵌套运用举例

来源:互联网 发布:淘宝客服业绩软件 编辑:程序博客网 时间:2024/06/05 14:09

==========================

main.xml

                         看mars老师的视频学习安卓里面的布局部分,做的样例,显摆一下,全部都是在main.xml里面配置的。

==========================

[html] view plaincopy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <LinearLayout  
  8.         android:layout_width="fill_parent"  
  9.         android:layout_height="fill_parent"  
  10.         android:layout_weight="1"  
  11.         android:orientation="horizontal" >  
  12.   
  13.         <TextView  
  14.             android:layout_width="wrap_content"  
  15.             android:layout_height="fill_parent"  
  16.             android:layout_weight="1"  
  17.             android:background="#0000aa"  
  18.             android:gravity="center_vertical"  
  19.             android:text="@string/hello"  
  20.             android:textSize="30dp" />  
  21.   
  22.         <TextView  
  23.             android:layout_width="wrap_content"  
  24.             android:layout_height="fill_parent"  
  25.             android:layout_weight="1"  
  26.             android:background="#00aa00"  
  27.             android:gravity="center_vertical"  
  28.             android:text="@string/hello"  
  29.             android:textSize="30dp" />  
  30.   
  31.         <TextView  
  32.             android:layout_width="wrap_content"  
  33.             android:layout_height="fill_parent"  
  34.             android:layout_weight="1"  
  35.             android:background="#0000aa"  
  36.             android:gravity="center_vertical"  
  37.             android:text="@string/hello"  
  38.             android:textSize="30dp" />  
  39.   
  40.         <TextView  
  41.             android:layout_width="wrap_content"  
  42.             android:layout_height="fill_parent"  
  43.             android:layout_weight="1"  
  44.             android:background="#00aa00"  
  45.             android:gravity="center_vertical"  
  46.             android:text="@string/hello"  
  47.             android:textSize="30dp" />  
  48.     </LinearLayout>  
  49.   
  50.     <LinearLayout  
  51.         android:layout_width="fill_parent"  
  52.         android:layout_height="fill_parent"  
  53.         android:layout_weight="1"  
  54.         android:orientation="vertical" >  
  55.   
  56.         <TextView  
  57.             android:layout_width="fill_parent"  
  58.             android:layout_height="wrap_content"  
  59.             android:layout_weight="1"  
  60.             android:background="#00aa00"  
  61.             android:gravity="center_horizontal"  
  62.             android:text="@string/hello"  
  63.             android:textSize="30dp" />  
  64.   
  65.         <TextView  
  66.             android:layout_width="fill_parent"  
  67.             android:layout_height="wrap_content"  
  68.             android:layout_weight="1"  
  69.             android:background="#0000aa"  
  70.             android:gravity="center_horizontal"  
  71.             android:text="@string/hello"  
  72.             android:textSize="30dp" />  
  73.   
  74.         <TextView  
  75.             android:layout_width="fill_parent"  
  76.             android:layout_height="wrap_content"  
  77.             android:layout_weight="1"  
  78.             android:background="#00aa00"  
  79.             android:gravity="center_horizontal"  
  80.             android:text="@string/hello"  
  81.             android:textSize="30dp" />  
  82.   
  83.         <TextView  
  84.             android:layout_width="fill_parent"  
  85.             android:layout_height="wrap_content"  
  86.             android:layout_weight="1"  
  87.             android:background="#0000aa"  
  88.             android:gravity="center_horizontal"  
  89.             android:text="@string/hello"  
  90.             android:textSize="30dp" />  
  91.     </LinearLayout>  
  92.   
  93. </LinearLayout>  
0 0
原创粉丝点击