5種常用佈局:
-
LinearLayout 線性佈局
orientation:vertical 垂直 horizontal 水平 -
RelativeLayout 相對佈局
設置相對位置
layout_center+InParent父佈局中央位置
+Vertical父佈局垂直居中位置
+Horizontal父佈局水平居中位置
layout_+above/below/toLeftOf/toRightOf在某控件上/下/左/右
layout_alignParentTop/Left/Right/Bottom與父控件上/左/右/下對齊
layout_alignTop/Left/Right/Bottom與某控件的上/左/右/下對齊設置間距
layout_marginTop/Left/Right/Bottom設置當前上/左/右/下邊界與某控件距離設置佈局內邊距
padding 四周
paddingTop/Left/Right/Bottom 上/左/右/下內邊距 -
FrameLayout 幀佈局
默認在屏幕左上角,按照放入順序重疊擺放。佈局大小由
foreground 前景圖像,位於所有子控件之上
foregroundGravity 設置前景圖像顯示位置 -
TableLayout 表格佈局 extends LinearLayout
配合TableRaw控件(行)使用,表格列數由包含最多控件的TableRaw決定佈局屬性:
stretchColumns 設置該列被拉伸
shrinkColumns 設置該列被收縮
collapseColumns 設置該列被隱藏控件屬性:
layout_column 設置單元格顯示位置
layout_span 設置單元格佔幾行(默認1行) -
AbsoluteLayout 絕對佈局
左上角爲原點。