服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Android - Android编程布局(Layout)之AbsoluteLayout用法实例分析

Android编程布局(Layout)之AbsoluteLayout用法实例分析

2021-04-23 15:312cto Android

这篇文章主要介绍了Android编程布局(Layout)之AbsoluteLayout用法,结合实例形式简单分析了Android绝对布局AbsoluteLayout的实现方法,需要的朋友可以参考下

本文实例讲述了android编程布局(layout)之absolutelayout用法。分享给大家供大家参考,具体如下:

absolutelayout,顾名思义,就是绝对位置的布局;也可以叫做坐标布局,也就是指定元素的绝对位置(或者叫绝对坐标值)。这种布局简单直接,直观性强,但是由于手机屏幕尺寸差别比较大,使用绝对定位的适应性会比较差。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?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>

效果如下:

Android编程布局(Layout)之AbsoluteLayout用法实例分析

如果不指定layout_x 和layout_y 那么默认都为0.回显示在最左上角。

希望本文所述对大家android程序设计有所帮助。

延伸 · 阅读

精彩推荐