ch05 Android布局
<div class="Section0">--------------------------------------------线性布局LineLayout----------------------------------<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ff0000"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="#00ff00"
android:text="用户名:" />
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#0000ff"
android:text="200" />
</LinearLayout>
</LinearLayout>
--------------------------------------------框架布局FrameLayout-------------------------------
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/FrameLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff0000"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<TextView
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_weight="1"
android:background="#00ff00"
android:text="100" />
<TextView
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_weight="2"
android:background="#0000ff"
android:text="200" />
</FrameLayout>
--------------------------------------------表格布局TableLayout--------------------------------
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/TableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="#ff0000"
android:text="1000" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00ff00"
android:text="2000" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="#0000ff"
android:text="3000" />
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="#0000ff"
android:text="1000" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#00ff00"
android:text="2000" />
</TableRow>
</TableLayout>
--------------------------------------------相对布局RelativeLayout-----------------------------
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/red"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:background="#ff0000"
android:gravity="center"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<TextView
android:id="@+id/green"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_above="@id/red"
android:layout_alignBaseline="@id/red"
android:layout_centerInParent="true"
android:background="#00ff00"
android:text="100" />
<TextView
android:id="@+id/blue"
android:layout_width="50dp"
android:layout_height="100dp"
android:layout_above="@id/red"
android:layout_toLeftOf="@id/green"
android:background="#0000ff"
android:text="200" />
</RelativeLayout>
--------------------------------------------绝对布局AbsoluteLayout-----------------------------
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/AbsoluteLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/red"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_x="0dp"
android:layout_y="100dp"
android:background="#ff0000"
android:gravity="center"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<TextView
android:id="@+id/green"
android:layout_width="150dp"
android:layout_height="100dp"
android:layout_x="0sp"
android:layout_y="200sp"
android:background="#00ff00"
android:text="100" />
<TextView
android:id="@+id/blue"
android:layout_width="50dp"
android:layout_height="100dp"
android:layout_x="0sp"
android:layout_y="300sp"
android:background="#0000ff"
android:text="200" />
</AbsoluteLayout>
线性布局LineLayout--------------------------------
http://dl.iteye.com/upload/attachment/0076/2527/85d7481a-08dc-348c-8073-b66b2f0c4dc5.png
框架布局FrameLayout------------------------------
http://dl.iteye.com/upload/attachment/0076/2529/67bff46c-725b-318f-b065-1c65fbcc6e06.png
表格布局TableLayout-------------------------------
http://dl.iteye.com/upload/attachment/0076/2531/48da8ed1-8ccb-3140-b6ea-73a678fa3708.png
相对布局RelativeLayout----------------------------
http://dl.iteye.com/upload/attachment/0076/2533/4a894e6b-5e07-351b-b811-39997cb8c001.png
绝对布局AbsoluteLayout---------------------------
http://dl.iteye.com/upload/attachment/0076/2535/a1b39ee9-61db-3283-867a-fe75d11464e5.png
页:
[1]