垂直线性布局:
<?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"
android:background="@drawable/background"
>
<Button android:text="按钮1" android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button android:text="按钮2" android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button android:text="按钮3" android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button android:text="按钮4" android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button android:text="按钮5" android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout> android
水平线性布局: 布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background"
>
<Button android:text="按钮1" android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<Button android:text="按钮2" android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<Button android:text="按钮3" android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<Button android:text="按钮4" android:layout_width="wrap_content"
android:layout_height="match_parent"/>
<Button android:text="按钮5" android:layout_width="wrap_content"
android:layout_height="match_parent"/>
</LinearLayout> xml
表格布局的登陆页面 utf-8
注意:android:stretchColumns="0,3"容许第一列和第四列伸缩,以配合为左右居中显示 input
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:gravity="center_vertical"
android:stretchColumns="0,3"
>
<!-- 第一行 -->
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView />
<TextView android:text="用户名:"
android:layout_width="wrap_content"
android:textSize="24sp"
android:layout_height="wrap_content"/>
<EditText android:layout_width="wrap_content"
android:textSize="24sp"
android:layout_height="wrap_content"
android:minWidth="200sp"/>
<TextView />
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView />
<TextView android:text="密 码:"
android:layout_width="wrap_content"
android:textSize="24sp"
android:layout_height="wrap_content"/>
<EditText android:layout_width="wrap_content"
android:textSize="24sp"
android:layout_height="wrap_content"
android:minWidth="200sp"
android:inputType="textPassword"/>
<TextView />
</TableRow>
<TableRow android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView />
<Button android:text="注 册"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button android:text="登 录"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView />
</TableRow>
</TableLayout> it
帧布局: io
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:id="@+id/mylayout"
android:foreground="@drawable/ic_launcher"
android:foregroundGravity="bottom|right"
>
<TextView android:text="红色背景的textView,显示在最下层"
android:background="#FFFF0000"
android:layout_gravity="center"
android:layout_width="380sp"
android:layout_height="380sp"/>
<TextView android:text="橙色背景的textView,显示在2层"
android:background="#FFFF6600"
android:layout_gravity="center"
android:layout_width="300sp"
android:layout_height="300sp"/>
<TextView android:text="黄色背景的textView,显示在2层"
android:background="#FFFFEE00"
android:layout_gravity="center"
android:layout_width="200sp"
android:layout_height="200sp"/>
</FrameLayout> 登录
相对布局: coding
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:id="@+id/mylayout"
>
<TextView
android:id="@+id/text1"
android:text="发现有新版本,您想如今就安装吗?"
android:textSize="24sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<Button
android:id="@+id/button1"
android:text="如今更新"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text1"
android:layout_toLeftOf="@+id/button2"
/>
<Button
android:id="@+id/button2"
android:text="之后再说"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/text1"
android:layout_below="@+id/text1"
/>
</RelativeLayout> layout