四种布局属性

线性布局LinearLayout:
只能水平/垂直方向单一排列
android:layout_width 宽
android:layout_height 高  属性值:fill_parent(不推荐), match_parent(匹配父容器),wrap_content(包围内容), 自定义尺寸
android:background 背景色  RGB,ARGB

android:gravity  内部对齐(容器内全部子控件均遵循该对齐方式) right, bottom, center(水平居中,垂直居中,正居中)
android:layout_gravity 外部对齐(针对某一个单独的子控件进行对齐,其他兄弟控件不受影响)......属性组合使用“|”

android:orientation 方向  属性值:horizontal(默认,水平方向),vertical(垂直方向)
android:layout_weight 权重(比喻成体重,代表子控件在同一方向上所占比重,注意:当使用该属性时,对应宽/高需要设置为“0dp”)



相对布局RelativeLayout:
可以相对父容器/兄弟控件位置任意摆放,布局灵活
android:layout_alignParentBottom 相对于父容器的底部。属性值:true/false
android:layout_alignParentTop  ..顶部
android:layout_alignParentLeft  ..左边
android:layout_alignParentRight  ..右边


android:layout_centerHorizontal  在父容器内水平居中
android:layout_centerVertical  在父容器内垂直居中
android:layout_centerInParent  在父容器正居中

android:layout_toLeftOf   在兄弟控件的左边
android:layout_toRightOf  ..右边
android:layout_above   ..上方
android:layout_below   ..下方

android: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   四周


帧布局FrameLayout:
子控件重叠摆放
android:foreground   前景色


网格布局GridLayout
诞生自Android4.0系统,特点:子控件不需要宽/高属性
android:rowCount  行数
android:columnCount  列数

android:layout_columnSpan 子控件占据列数
android:layout_rowSpan  子控件占据行数



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值