计应112 贺利琴
Android布局主要有以下几种:1.线性布局( LinearLayout);2.相对布局( RelativeLayout);3.绝对布局(AbsoluteLayout);4.表格布局(TableLayout)。
LinearLayout线性布局,包含在LinearLayout里面的控件按顺序排列成一行或者一列,它的常用的属性主要包括:
例如:在一个大的LinearLayout中两个小的LinearLayout,在这两个LinearLayout中分别有三个文本框,按照垂直线性排列和水平线性排列,其比例均为:1:1:1。布局如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="0px"
android:orientation="horizontal" android:background="#ff0000" android:layout_weight="1">
<TextView
android:id="@+id/textView1"
android:layout_width="0px"
android:layout_height="fill_parent"
android:text="1" android:background="#ff0000" android:layout_weight="1"/>
<TextView
android:id="@+id/textView2"
android:layout_width="0px"
android:layout_height="fill_parent"
android:text="2" android:background="#0000ff" android:layout_weight="1"/>
<TextView
android:id="@+id/textView3"
android:layout_width="0px"
android:layout_height="fill_parent"
android:text="3" android:background="#00ffff" android:layout_weight="1"/>
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0px"
android:orientation="vertical" android:layout_weight="1">
<TextView
android:id="@+id/textView4"
android:layout_width="fill_parent"
android:layout_height="0px"
android:text="4" android:background="#00ff00" android:layout_weight="1"/>
<TextView
android:id="@+id/textView5"
android:layout_width="fill_parent"
android:layout_height="0px"
android:text="5" android:background="#ff0000" android:layout_weight="1"/>
<TextView
android:id="@+id/textView6"
android:layout_width="fill_parent"
android:layout_height="0px"
android:text="6" android:background="#ffff00" android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>