Android五大布局之一絕對布局(AbsoluteLayout)

來源:互聯網
上載者:User

標籤:xmlns   技術   技術分享   使用   com   res   android   abs   androi   

一.AbsoluteLayout(絕對布局)重點:

AbsoluteLayout(絕對布局)之所以把這個放到最後,是因為絕對布局,我們基本上都是不會使用的,我們開發的應用需要在很多的機型上面進行一個適配,如果你使用了這個絕對布局的話,可能你在4寸的手機上是顯示正常的,而換成5寸的手機,就可能出現位移和變形,所以的話,這個還是不建議使用了

二.AbsoluteLayout(絕對布局)常用屬性:

控制大小: 

android:layout_width:組件寬度 android:layout_height:組件高度 

控制位置: 
android:layout_x:設定組件的X座標 android:layout_y:設定組件的Y座標

三.例子(主要呈現android:layout_x、android:layout_y控制控制項的位置)

1.首先我們先建立一個AbsoluteLayout的XML檔案

代碼如下:

 1 <?xml version="1.0" encoding="utf-8"?> 2 <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" 3     android:layout_width="match_parent" 4     android:layout_height="match_parent" > 5  6     <Button 7         android:id="@+id/button1" 8         android:layout_width="wrap_content" 9         android:layout_height="wrap_content"10         android:layout_x="32dp"11         android:layout_y="53dp"12         android:text="Button" />13 14     <Button15         android:id="@+id/button2"16         android:layout_width="wrap_content"17         android:layout_height="wrap_content"18         android:layout_x="146dp"19         android:layout_y="53dp"20         android:text="Button" />21 22     <Button23         android:id="@+id/button3"24         android:layout_width="wrap_content"25         android:layout_height="wrap_content"26         android:layout_x="85dp"27         android:layout_y="135dp"28         android:text="Button" />29 30 </AbsoluteLayout>

運行結果如下:

 

以上就是我對AbsoluteLayout(絕對布局)理解

Android五大布局之一絕對布局(AbsoluteLayout)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.