<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical"
android:layout_weight="1" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="fill_parent"
android:textSize="15sp" android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
android:layout_height="wrap_content" android:background="#56789a"></TextView>
<TextView android:layout_width="fill_parent"
android:textSize="15sp" android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
android:layout_height="wrap_content" android:background="#456789"></TextView>
<TextView android:layout_width="fill_parent"
android:textSize="15sp" android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
android:layout_height="wrap_content" android:background="#345678"></TextView>
<TextView android:layout_width="fill_parent"
android:textSize="15sp" android:layout_weight="1"
android:gravity="center_horizontal|center_vertical"
android:layout_height="wrap_content" android:background="#234567"></TextView>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_weight="1" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="fill_parent"
android:layout_weight="1" android:gravity="center_horizontal|center_vertical"
android:layout_height="fill_parent" android:background="#56789a"></TextView>
<TextView android:layout_width="fill_parent"
android:layout_weight="1" android:gravity="center_horizontal|center_vertical"
android:layout_height="fill_parent" android:background="#456789"></TextView>
<TextView android:layout_width="fill_parent"
android:layout_weight="1" android:gravity="center_horizontal|center_vertical"
android:layout_height="fill_parent" android:background="#345678"></TextView>
<TextView android:layout_width="fill_parent"
android:layout_weight="1" android:gravity="center_horizontal|center_vertical"
android:layout_height="fill_parent" android:background="#234567"></TextView>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:gravity="right" android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:text="確定" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
<Button android:text="取消" android:layout_width="wrap_content"
android:layout_height="wrap_content">
</Button>
</LinearLayout>
</LinearLayout>
<!-- gravity:設置LinearLayout內控件的對齊方式 -->
<!-- orientation:設置LinearLayout的線性對齊方式 -->
AbsoluteLayout佈局:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_x="10px"
android:layout_y="10px"
android:background="#0000FF"></TextView>
</AbsoluteLayout>
<!-- 絕對定位 指定子控件的xy精確座標的佈局。缺乏靈活性。 -->
FrameLayout佈局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TextView android:layout_width="290dp" android:layout_height="290dp"
android:layout_gravity="center" android:background="#00FF11" />
<TextView android:layout_width="260dp" android:layout_height="260dp"
android:layout_gravity="center" android:background="#00EE22" />
<TextView android:layout_width="230dp" android:layout_height="230dp"
android:layout_gravity="center" android:background="#00DD33" />
<TextView android:layout_width="200dp" android:layout_height="200dp"
android:layout_gravity="center" android:background="#00CC44" />
</FrameLayout>
<!-- FrameLayout中的控件是層疊形式的。 -->
<!-- layout_gravity: 指定控件在整個容器中的位置。 -->
<!-- gravity:指定控件內部的內容在控件中的位置。 -->
<!-- 如:1中有2,2中有3 在2中用layout_gravity標識2在1中的位置。 在2中用gravity標識2中的3在2中的位置。 -->