.Net程式員玩轉Android開發---(9)絕對布局AbsoluteLayout

來源:互聯網
上載者:User

標籤:android開發   布局   absolutelayout   遊響雲停工作室   移動端開發   

      絕對布局AbsoluteLayout類似於.NET中Winform的布局方式,以表單左上方為座標點,向右向下延伸. 由於絕對布局每個控制項的位置是固定的,不能隨著螢幕的大小改變而改變,所以在不同裝置上運行出來的效果不同,所以這種布局方式使用的比較少。

      絕對布局AbsoluteLayout中的控制項有兩個重要屬性layout_x和layout_y分別用來設定控制項的絕對位置。


       下面我們看下這個例子布局的效果

       

         

<?xml version="1.0" encoding="utf-8"?><AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent" >    <ImageView        android:id="@+id/imageView1"        android:layout_width="96dp"        android:layout_height="96dp"        android:layout_x="0dp"        android:layout_y="3dp"        android:src="@raw/pad" />    <TextView        android:id="@+id/textView2"        android:layout_width="120dp"        android:layout_height="wrap_content"        android:layout_x="110dp"        android:layout_y="78dp"        android:text="商品顏色:白色" />    <TextView        android:id="@+id/textView2"        android:layout_width="120dp"        android:layout_height="wrap_content"        android:layout_x="110dp"        android:layout_y="47dp"        android:text="商品價格:$19" />    <TextView        android:layout_width="120dp"        android:layout_height="wrap_content"        android:layout_x="110dp"        android:layout_y="16dp"        android:text="商品名稱:Ipad Air" />    <TextView        android:id="@+id/textView1"        android:layout_width="match_parent"        android:layout_height="3dp"        android:layout_x="0dp"        android:layout_y="118dp"        android:background="#EEE8CD"        android:text="" />    <ImageView        android:id="@+id/ImageView01"        android:layout_width="96dp"        android:layout_height="96dp"        android:layout_x="9dp"        android:layout_y="137dp"        android:src="@raw/pad" />    <TextView        android:layout_width="120dp"        android:layout_height="wrap_content"        android:layout_x="118dp"        android:layout_y="144dp"        android:text="商品名稱:Ipad Air" />    <TextView        android:id="@+id/TextView01"        android:layout_width="120dp"        android:layout_height="wrap_content"        android:layout_x="118dp"        android:layout_y="206dp"        android:text="商品顏色:白色" />    <TextView        android:id="@+id/TextView01"        android:layout_width="120dp"        android:layout_height="wrap_content"        android:layout_x="118dp"        android:layout_y="176dp"        android:text="商品價格:$19" />    <TextView        android:id="@+id/TextView02"        android:layout_width="match_parent"        android:layout_height="3dp"        android:layout_x="2dp"        android:layout_y="261dp"        android:background="#EEE8CD" /></AbsoluteLayout>



.Net程式員玩轉Android開發---(9)絕對布局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.