线性布局:LinerLayout
表格布局:TableLayout
相对布局:RelativeLayout
绝对布局:AbsoluteLayout
帧布局:FrameLayout
定义并展现视图层次的最常用的方法是使用XML布局文件。XML中的每个元素都是View或ViewGroup对象(或他们的子类)。
1.线性布局
注:纵向vertical或横向horizontal
eg:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout//<TextView>没有在该命名空间中,因此其前面无需加上“android:”做前缀
xmlns:android="http://schemas.android.com/apk/res/android" //其属性“xmlns:android”指定命名空间,顶级元素必须指定命名空间。
android:orientation="vertical"//属性“orientation”指定子元素排列方式,其中指定为“vertical”则是子元素垂直排列,而另一个为“horizontal”代表子元素水平排列,
android:layout_width="fill_parent"//“fill_parent”=“match_parent”代表填满其父元素,“wrap_content”代表该元素的大小仅包裹其自身内容
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"//layout_width该元素的宽度
android:layout_height="wrap_content"//layout_height该元素的高度
android:text="@string/name_text"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancle_button"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/ok_button"/>
</LinearLayout>
2.表格布局:
TableLayout属于行和列形式的管理控件,每行为一个TableRow对象,也可以是一个View对象。
在TableRow中还可以继续添加其他的控件,每添加一个子控件就成为一列。TableLayout不会生成边框。
Android:collapseColumns 设置指定的列为collapse,如果一列被标示为collapse,该列会被隐藏
Android:shrinkColumns 设置指定的列为shrinkable,如果一列被标示为shrinkableÿ