布局:
<LinearLayout></LinearLayout>
<RelativeLayout></RelativeLayout>
<FrameLayout></FrameLayout>
<TableLayout></TableLayout>
四种布局的公共属性:
android:id="@+id/id_name"
android:layout_width="wrap_content"
="match_parent"
android:layout_height="wrap_content"
="match_parent"
android:text="message" ||显示文字
android:src="@drawable/ic_launcher" ||显示图片
android:hint="tips" ||提示文字
android:inputType="textPassword" ||按照密文的方式输入,隐藏输入内容
...
<LinearLayout></LinearLayout>
属性:
android:orientation="vertical" ||垂直
="horizontal" ||水平
android:layout_gravity="top"
="bottom"
="center"
="center_vertical"
="center_horizontal"
...
android:layout_weight="1" ||权重
<RelativeLayout></RelativeLayout>
属性:
android:layout_alignParentLeft="true" ||对齐于父类的左侧
="false"
android:layout_alignParentRight="true" ||对齐于父类的右侧
="false"
android:layout_alignParentTop="true" ||对齐于父类的上侧
="false"
android:layout_alignParentBottom="true" ||对齐于父类的底侧
="false"
android:layout_centerInParent="true" ||对齐于父类的中心
="false"
android:layout_above="@id/id_name" ||在某一控件的上方(注意要先定义被引用的控件)
android:layout_below="@id/id_name" ||在某一控件的下方
android:layout_toLeftOf="@id/id_name" ||在某一控件的左方
android:layout_toRightOf="@id/id_name" ||在某一控件的右方
android:layout_alignLeft="@id/id_name" ||本控件的左边缘和某一控件的左边缘对齐
android:layout_alignRight="@id/id_name ||本控件的右边缘和某一控件的右边缘对齐
android:layout_alignTop="@id/id_name" ||本控件的上边缘和某一控件的上边缘对齐
android:layout_alignBottom="@id/id_name" ||本控件的下边缘和某一控件的下边缘对齐
<FrameLayout></FrameLayout>
属性:
全部控件均摆放在布局的左上角(碎片)
<TableLayout></TableLayout>
属性:
<TableRow></TableRow> 在表格中添加一行,TableRow中添加一个控件则增加一列
属性:
android:layout_span="2" ||占据2列的空间
android:stretchColumns="1" ||拉伸第2列使的行充满父类
android:stretchColumns="0" ||拉伸第1列使的行充满父类