Ardroid 常见界面布局

1.相对布局RelativeLayout

1.1 相对父容器布局

android:layout_width="match_parent(充满父)/wrap_content(根据本身)"    控件的宽度

android:layout_height=match_parent/wrap_content""   控件的高度

android:layout_alignParentTop="true/false"   是否顶对齐

android:layout_marginTop="30dp"  控件与父容器上边的距离

android:layout_alignParentBottom="true/false"   是否底对齐

android:layout_marginBottom="30dp"    下边的距离

android:layout_alignParentLeft="true/false"    是否左对齐

android:layout_marginLeft="30dp"       左边的距离

android:layout_alignParentRight="true/false"    是否右对齐

android:layout_marginRight="30dp"  右边的距离

android:layout_centerHorizontal="true/false"     设置是否相对父容器水平居中

android:layout_centerVertical="true/false"       设置是否相对父容器垂直居中

android:layout_centerInParent="true/false"    设置是否相对父容器中居中

1.2相对控件布局

android:layout_above="@id/已知控件id"    未知控件位于已知控件之上

android:layout_marginBottom="30dp"      未知控件下边与已知控件的距离

android:layout_below="@id/已知控件id"     位于已知控件之下

android:layout_Top="30dp"    上边与已知控件的距离

android:layout_toLeftOf="@id/已知控件id"      位于已知控件左边

android:layout_marginRight="30dp"       右边与已知控件的距离

android:layout_toRightOf="@id/已知控件id"    位于已知控件右边

android:layout_marginLeft="30dp"    左边与已知控件的距离

2.线性布局LinearLayout

2.1水平线性布局

android:layout_orientation="horizontal"      水平布局

2.2垂直线性布局

android:layout_orientation="vertical"       垂直水平

附:android:layout_gravity="位置"        控件本身的对齐方式

android:gravity="位置"       包含在里面的控件对齐方式

3.表格布局TableLayout

一行为一个TableRow(<TableRow 属性>控件1...控件n</TableRow>)里面的一个控件为一个单元格

android:stretchColumns="列数"     指定该列被拉伸,列号从0开始

android:shrinkColumns="列数"       指定该列被收缩,列号从0开始

android:collapseColumns="列数"      指定该列被隐藏,列号从0开始

4.网格布局GridLayout

布局就是将界面分割成行、列、单元

android:columnCount="数字"       分割成几列

android:rowCount="数字"          分割成几行

android:layout_column="数字"     控件所在第几列

android:layout_row="数字"         控件所在第几行

android:layout_rowSpan="数字"      控件跨越行数

android:layout_gravity=" "        控件位置

5.帧布局FrameLayout  重叠

垂直滚动视图ScrollView

<ScrollView  属性></ScrollView>

水平滚动视图HorizontalScrollView

<HorizontalScrollView 属性></HorizontalScrollView>

原文地址:https://www.cnblogs.com/ZSK991656110/p/4807111.html