安卓第二章 常见的五种布局

安卓第二章 常见的四种布局

1.线性布局LinearLayout

分为水平线性布局和垂直线性布局都是在水平或者垂直方向单一排列

android:layout_width   宽度

android:layout_height   高度

 

属性值:fill_parent(不推荐使用了) ,match_parent (匹配父容器),

       wrap_content(包围内容),自定义尺寸(具体的值)

 

android:background 背景色

 

RGB &ARGB  颜色以及加了透明度的颜色

 

对齐方式:

android:gravity  内部对齐(容器内全部子控件遵循该对齐方式)(水平居中,垂直居中,正居中)

android:layout_gravity  外部对齐(针对某一个单独的子控件进行对齐,其他兄弟控件不收影响)

 

android:orientation 对齐的方向 horizontal(默认,水平方向),vertical 垂直方向

 

android:layout_weight 权重(可以将其比喻成体重,代表子控件在某一个方向上所占的比重,注意:当使用该属性的时候,对应的宽高需要设置为  0dp)。

 

 

 

 

2.相对布局RelativeLayout

可以相对父容器/兄弟控件位置任意摆放,布局灵活

android:layout_alignParentBootom: 相对于父容器的底部  属性值:true/false

android:layout_alignParentTop:                 的顶部  ………….

android:layout_alignParentLeft:                   左边   ……..

android:yout_alignParentRight                 右边    ……..

 

android:layout_centerhorization  在父容器内水平居中

android:layout_centerInParent   在父容器内垂直居中

android:layout_toLeftOf                    在兄弟控件的左边

android:layout_toRightOf                 ..右边

android:layout_above                        ..上方

android:layout_below                        ..下方

 

anroid:layout_alignLeft        自己的左边与兄弟控件的左边对齐

android:layout_alignRight      自己的右边与兄弟控件的右边对齐

android:layout_alignTop        自己的顶部与兄弟控件的顶部对齐

android:layout_alignBottom     自己的底与兄弟控件的底部对齐

android:layout_alignBaseLine   文本视图,对齐文本的基准线

android:layout_marginLeft               左侧外边距(子控件使用,其他兄弟控件不受影响)

android:layout_marginRight            右侧..

android:layout_marginTop                顶部..

android:layout_marginBottom                 底部..

android:layout_margin                      四周..

 

android:paddingLeft                           左侧内边距(容器使用,容器内全部子控件均受到影响。该属性同样可以适用于TextView等控件,使控件和控件内的内容有内间距)

android:paddingRight                         右侧..

android:paddingTop                            顶部..

android:paddingBottom                    底部..

android:padding                         四周

 

 

 

3.帧布局FrameLayout

子控件重叠摆放

android:foreground  前景色

4. 网格布局GridLayout

诞生自Android4.0系统,特点:子控件不需要宽/高属性

android:rowCount                行数

android:columnCount               列数

 

android:layout_columnSpan    子控件占据列数

android:layout_rowSpan          子控件占据行数

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值