B站学习链接:
【【android基础系列P2】安卓开发UI布局-推荐1.5倍速】https://www.bilibili.com/video/BV1Ht411371u?p=9&vd_source=ea4fd980a0459b2d8de30f00bcb4234f
线性布局 - 横排/竖排线性排列 | |
方向orientation | 横向/竖向线性排列 |
权重 | (layout_width=0)按比例分配宽/高 |
ConstraintLayout(RelativeLayout)相对布局 - 参照其他对象定位 | |
layout_aliginParentRight(Bottom) | 相对父view的位置,默认/中间/右上/右下 |
layout_toleftof(layout_aboveof) = 控件id | 相对于同级控件 |
layout_margintop/marginLeft | 边缘留白空余 |
AbsoluteLayout -- 绝对布局 , 绝对坐标定位 | |
TableLayout表格布局 - 按表格样式行列排列(TableRow) | |
FrameLayout - 帧布局 - view | |
布局单位 | |
像素px | 图片最小的单位,不推荐使用 |
dp(dip) | 适配屏幕的单位(布局推荐使用,适配多机型位置不变)160dp下和px1:1 (和像素换算 像素 * 160dp/屏幕dp = dp大小) |
sp | 字体的单位 |
控件常用属性 | |
宽/高 | layout_width/layout_height |
layout_gravity | 设置该View相对与父View的位置(right/left/center/top/center_vertical) |
背景颜色、图像 | background (比如计算器按钮的背景边框drawable) |