Android开发之路四-------布局
Android的布局在主窗口上主要是分为四类,LinerLayout(线性布局),RelativeLayout(相对布局),TableLayout(表格布局),FreamLayout(帧布局)。下面就我来详细的介绍这四种布局的特点。
一、LinerLayout布局
所谓的线性布局就是在该标签下的所有子元素会根据其orientation属性的值来确定是按行还是按列来显示的。结合代码来看一下
<?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" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/name_text"
/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="2,1"
>
<TableRow >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/yh_text"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</TableRow>
<TableRow >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/mm_text" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</EditText>
</TableRow>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"