常用的UI布局

线性布局

http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical" >

android:id="@+id/editText1"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="To" >

android:id="@+id/editText2"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Subject" />

android:id="@+id/editText3"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:gravity="top"

android:hint="massage" />

android:layout_width="match_parent"

android:layout_height="wrap_content" >

android:id="@+id/button1"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:text="reset"

android:layout_weight="1" />

android:id="@+id/button2"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:text="send"

android:layout_weight="1" />


对布局


http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:id="@+id/ed_retive_massage"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:layout_alignParentTop="true"

android:hint="Message" >

android:id="@+id/btn_revtie_ok"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentRight="true"

android:layout_below="@+id/ed_retive_massage"

android:text="Ok" />

android:id="@+id/btn_revtie_cancel"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Cancel"

android:layout_alignTop="@id/btn_revtie_ok"

android:layout_toLeftOf="@id/btn_revtie_ok"

android:layout_marginRight="10dp" />

帧布局


http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:layout_width="280dp"

android:layout_height="280dp"

android:background="#33FFFF"

android:layout_gravity="center"

/>

android:layout_width="220dp"

android:layout_height="220dp"

android:background="#33CCFF"

android:layout_gravity="center"

/>

android:layout_width="180dp"

android:layout_height="180dp"

android:background="#3399FF"

android:layout_gravity="center" />

android:layout_width="140dp"

android:layout_height="140dp"

android:background="#3366FF"

android:layout_gravity="center" />

android:layout_width="100dp"

android:layout_height="100dp"

android:background="#3300FF"

android:layout_gravity="center" />

内边距与外边距


http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:id="@+id/textView1"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_margin="20dp"

android:paddingLeft="60dp"

android:hint="Message" />


android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignRight="@+id/textView1"

android:layout_below="@+id/textView1"

android:layout_marginTop="20dp"

android:text="OK" />

表格布局


http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:layout_width="match_parent"

android:layout_height="wrap_content"

>

android:layout_width="0dp"

android:layout_height="wrap_content"

android:text="1241"

android:gravity="center"

android:layout_weight="1"

/>

android:layout_width="0dp"

android:layout_height="wrap_content"

android:text="我中意你啊"

android:gravity="center"

android:layout_weight="1"

/>

android:layout_width="match_parent"

android:layout_height="wrap_content" >

android:layout_width="0dp"

roid:layout_weight="1" />

android:layout_width="0dp"

android:layout_height="wrap_content"

android:text="我中意你啊"

android:gravity="center"

android:layout_weight="1" />

你可能感兴趣的:(常用的UI布局)