android中常用布局

1、线性布局 ( LinearLayout )

2、相对布局  (RelativeLayout)

3、帧布局       (FrameLayout)

4、表格布局     (TableLayout)

5、绝对布局    (AbsoluteLayout)

1、线性布局(LinearLayout)

LinearLayout是线性布局控件:要么横向排布,要么竖向排布

android:orientation:vertical (垂直  方向) 、horizontal(水平  方向)

常用属性

android:gravity------------设置控件自身上面的内容位置

android:layout_gravity-----设置控件本身相对于父控件的显示位置

android:layout_weight----- 设置控件分配剩余空间

gravity:对齐方式,子控件相对于当前控件的对齐方式

layout_gravity:对齐方式,当前控件相对与父控件的对齐方式

magin :当前控件相对四周的间距(layout_marginTop,layout_marginLeft,layout_marginRight,layout_marginBottom)

android:layout_marginStart:本元素离开始的位置的距离

android:layout_marginEnd:本元素离结束位置的距离

padding : 当前控件中的子控件相对于当前控件的四周的间距


2、相对布局(RelativeLayout)

android:layout_below 位于某个控件的下方

android:layout_above 位于某个控件的上方

android:layout_toLeftOf 位于某个控件的左方

android:layout_toRightOf 位于某个控件的右方

android:layout_alignParentRight 当前控件基于父窗体的对齐方式

android:layout_centerHorizontal 水平居中

android:layout_centerVertical  垂直居中

android:layout_centerInParent 位于父窗体 的中间

3、帧布局 (FrameLayout)

帧布局中的子控件都是一层一层向上叠加的

4、表格布局 (TableLayout)

TableLayout 中的一个TableRow 代表一行 TableRow中的一个控件代表一列

5、绝对布局 (AbsoluteLayout)已被抛弃

你可能感兴趣的:(android中常用布局)