Android編程布局(Layout)之AbsoluteLayout用法實例分析
更新時間:2015年12月22日 15:29:14 作者:2cto
這篇文章主要介紹了Android編程布局(Layout)之AbsoluteLayout用法,結(jié)合實例形式簡單分析了Android絕對布局AbsoluteLayout的實現(xiàn)方法,需要的朋友可以參考下
本文實例講述了Android編程布局(Layout)之AbsoluteLayout用法。分享給大家供大家參考,具體如下:
AbsoluteLayout,顧名思義,就是絕對位置的布局;也可以叫做坐標布局,也就是指定元素的絕對位置(或者叫絕對坐標值)。這種布局簡單直接,直觀性強,但是由于手機屏幕尺寸差別比較大,使用絕對定位的適應性會比較差。
<?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 那么默認都為0.回顯示在最左上角。
希望本文所述對大家Android程序設(shè)計有所幫助。
相關(guān)文章
搭建mac使用Charles抓包安卓app環(huán)境配置過程
這篇文章主要為大家介紹了mac使用Charles抓包,安卓app環(huán)境搭建的配置過程步驟,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步2022-02-02
Android Studio實現(xiàn)簡單計算器APP
這篇文章主要為大家詳細介紹了Android Studio實現(xiàn)簡單計算器APP,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-03-03
Android 通過Messager與Service實現(xiàn)進程間雙向通信案例詳解
這篇文章主要介紹了Android 通過Messager與Service實現(xiàn)進程間雙向通信案例詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-09-09

