android學習筆記5:絕對布局

來源:互聯網
上載者:User

在使用android的介面開發工具droiddraw的時候,你會發現,它的預設布局就是絕對布局,也就是用座標來指定每一個控制項的位置,這樣的方法在直接拖控制項的時候顯的比較方便,但是不利於程式的推廣和後期的調整,所以還是建議不使用絕對布局。下面的這個程式是用絕對布局做的一個登入介面,很簡單,就只把xml檔案貼出來了。

     

<?xml version="1.0" encoding="utf-8"?><AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><!-- 定義一個文字框,使用絕對位置 --><TextView android:layout_x="20dip"android:layout_y="20dip"android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="使用者名稱:"/><!-- 定義一個文本編輯框,使用絕對位置 --><EditText android:layout_x="80dip"android:layout_y="15dip"android:layout_width="wrap_content" android:width="200px" android:layout_height="wrap_content" /><!-- 定義一個文字框,使用絕對位置 --><TextView android:layout_x="20dip"android:layout_y="80dip"android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="密  碼:"/><!-- 定義一個文本編輯框,使用絕對位置 --><EditText android:layout_x="80dip"android:layout_y="75dip"android:layout_width="wrap_content" android:width="200px" android:layout_height="wrap_content" android:password="true"/><!-- 定義一個按鈕,使用絕對位置 --><Button android:layout_x="130dip"android:layout_y="135dip"android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="登   錄"/></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.