Android編程布局(Layout)之AbsoluteLayout用法實例分析
本文實例講述了Android編程布局(Layout)之AbsoluteLayout用法。分享給大家供大家參考,具體如下:
AbsoluteLayout,顧名思義,就是絕對位置的布局;也可以叫做坐標(biāo)布局,也就是指定元素的絕對位置(或者叫絕對坐標(biāo)值)。這種布局簡單直接,直觀性強(qiáng),但是由于手機(jī)屏幕尺寸差別比較大,使用絕對定位的適應(yīng)性會比較差。
<?xml version = "1.0" encoding = "utf-8"?> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="10dip"> <TextView android:id="@+id/lable" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="請輸入用戶名:"/> <EditText android:id="@+id/text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_x="100dip" android:layout_y="20dip"/> <Button android:id="@+id/cancel" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="10dip" android:layout_y="50dip" android:text="取消"/> <Button android:id="@+id/ok" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="60dip" android:layout_y="50dip" android:text="確定"/> </AbsoluteLayout>
效果如下:
如果不指定Layout_x 和Layout_y 那么默認(rèn)都為0.回顯示在最左上角。
希望本文所述對大家Android程序設(shè)計有所幫助。
相關(guān)文章
Android源碼系列之深入理解ImageView的ScaleType屬性
Android源碼系列第一篇,這篇文章主要從源碼的角度深入理解ImageView的ScaleType屬性,感興趣的小伙伴們可以參考一下2016-06-06Android實現(xiàn)點擊AlertDialog上按鈕時不關(guān)閉對話框的方法
這篇文章主要介紹了Android實現(xiàn)點擊AlertDialog上按鈕時不關(guān)閉對話框的方法,涉及設(shè)置監(jiān)聽的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-02-02Flutter檢查連接網(wǎng)絡(luò)connectivity_plus實現(xiàn)步驟
這篇文章主要為大家介紹了Flutter檢查連接網(wǎng)絡(luò)connectivity_plus實現(xiàn)步驟,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06詳解Android Studio中Git的配置及協(xié)同開發(fā)
這篇文章主要介紹了詳解Android Studio中Git的配置及協(xié)同開發(fā),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-03Android仿微信@好友功能 輸入@跳轉(zhuǎn)、刪除整塊
這篇文章主要介紹了Android仿微信@好友功能 輸入@跳轉(zhuǎn)、刪除整塊,代碼簡單易懂,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-10-10Android?IdleHandler基本使用及應(yīng)用案例詳解
這篇文章主要為大家詳細(xì)介紹了Android?IdleHandler的基本使用及應(yīng)用案例,文中的示例代碼講解詳細(xì),具有一定的參考價值,需要的可以參考一下2022-10-10