Android编程布局(Layout)之AbsoluteLayout用法实例分析
本文实例讲述了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程序设计有所帮助。
相关文章
Android源码系列之深入理解ImageView的ScaleType属性
Android源码系列第一篇,这篇文章主要从源码的角度深入理解ImageView的ScaleType属性,感兴趣的小伙伴们可以参考一下2016-06-06Android实现点击AlertDialog上按钮时不关闭对话框的方法
这篇文章主要介绍了Android实现点击AlertDialog上按钮时不关闭对话框的方法,涉及设置监听的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下2015-02-02Flutter检查连接网络connectivity_plus实现步骤
这篇文章主要为大家介绍了Flutter检查连接网络connectivity_plus实现步骤,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2023-06-06Android IdleHandler基本使用及应用案例详解
这篇文章主要为大家详细介绍了Android IdleHandler的基本使用及应用案例,文中的示例代码讲解详细,具有一定的参考价值,需要的可以参考一下2022-10-10
最新评论