Android布局_LinearLayout布局

來源:互聯網
上載者:User

一、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 布局, 可以提供頁面的垂直滾動功能,有垂直捲軸。 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.