一、LinearLayout(线性布局)
常用属性:
A. android:orientation="vertical" 或者 android:orientation="horizontal" ——决定子类控件垂直或者水平排布
B. android:gravity = "center_horizontal | bottom" ——决定子类控件的X、Y位置
center:垂直水平都居中 right(右)、left(左)、bottom(下面)
center_vertical:垂直(Y轴)居中
center_horizontal:水平(X轴)居中
C. android:layout_gravity="bottom" ——指的是子控件本身在当前父容器的X、Y位置
android:layout_weight="1" ——指的是子控件本身占当前父容器的一个比例(wrap_content正比、match_parent反比)
注意:即使设置了也不一定起作用。比如:水平的LinearLayout要从左边开始依次放置布局,所以设置TextView的layout_gravity属性为right也不起作用。
二、RelativeLayout(相对布局)
常用属性:(align 系列、margin系列、center系列)
(1)以下属性是 子类控件 相对于 父类(RelativeLayout)的)
B.使用android:background——设置背景
C.使用android:keepScreenOn——保持屏幕唤醒
D.使用android:foregroundGravity——设置前景图的位置
android:layout_y="29dp" ——控制当前子控件的Y位置