Android中LinearLayout布局的常用属性总结
16lz
2021-01-24
基本属性要求
- android:orientation
- 决定是水平排列或是垂直排列
- vertical 垂直排列
- horizontal 水平排列
垂直排列 Button
水平排列 Button
重心设定
- android:gravity
- 设定框架的内容的放置方向
- center 水平垂直皆置中
- center_vertical 垂直置中
- center_horizontal 水平置中
- top 置顶
- left 置左
- bottom 置底
- right 置右
水平、垂直置中
透过 OR 运算子组合重心
比例分配
- android:layout_weight
- 子元件或子框架的比重。
- LinearLayout 下的子元件或子框架,才能设定这项属性。
等比例分配
比重都是 1,所以大小相同。
非等比例分配
.10 代表 0.10
.20 代表 0.20
.70 代表 0.70
合起来刚好是 1 ,作 100% 分配。
更多相关文章
- LinearLayout中组件右对齐
- Android(安卓)Layout 之TableLayout
- 使用LinearLayout线性布局编写左上右上左下右下中央
- Android(安卓)对Layout_weight属性完全解析以及使用ListView来实
- Android界面五种常用布局方式
- Android(安卓)RecyclerView之代替ListView与GridView
- UI组件之 ProgressBar及其子类(一)ProgressBar进度条的使用
- Android(安卓)自定义WheelView滚动控件
- Android(安卓)LinearLayout中元素按比例分配宽度