一、LinearLayout 布局,類似於一個盒子1. 主要屬性有:(1)android:orientation設定LinearLayout容器布局組件的方式:要麼按行要麼按列。只能取值:horizontal、vertical。(2)android:gravity設定布局在LinearLayout容器內的組件的對齊。取值包括:top、bottom、left、right、center、start、end等。 2. 所有放置在LinearLayout中的組件都必須通過android:layout_width和android:layout_height屬性來告知LinearLayout如何對組件進行布局。有三個可選的值:match_parent/fill_parent----佔滿父容器的所有空間;wrap_content ----組件將只佔用為了正確顯示器內容所需的空間;一個常數值和單位,可用的單位:l px(像素):螢幕上的點。l in(英寸):長度單位。l mm(毫米):長度單位。l pt(磅):1/72英寸。l dp(與密度無關的像素):一種基於螢幕密度的抽象單位。在每英寸160點的顯示器上,1dp=1px。l dip:與dp相同,多用於Google樣本中。l sp(與刻度無關的像素):與dp類似,但是可以根據使用者的字型大小喜好設定進行縮放。 3. weight 屬性,權值android:layout_weight 設定組件佔用容器的空餘顯示空間的比例。在使用垂直布局的情況下,使用android:layout_weight時,需要設定android:layout_height的值為0;在使用水平布局的情況下,使用android:layout_weight時,需要設定android:layout_width的值為0。在LinearLayout下才有android:layout_weight 屬性,主要是為了按百分比進行布局 二、其他的布局1. RelativeLayout 布局 (相對布局)工程建立後的預設布局2. TableLayout布局,表格版面配置,可以利用 android:layout_span 屬性進行合并,使用表格版面配置時,一般將組建嵌套在 <TableRow></TableRow> 中。3. ScrollView 布局, 可以提供頁面的垂直滾動功能,有垂直捲軸。