vAbsoluteLayout:像AWT的空布局一样,布局管理器不提供任何布局控制,而是由开发人员自己通过XY坐标来控制组件的位置。

v当使用绝对布局时,布局容器不再管理组件的大小、位置,全部由开发人员自己控制。
v在绝大部分情况下,不推荐使用绝对布局,因为手机屏幕的大小、分辨率各不相同,使用绝对布局很难保证应用的通用性。
v使用绝对布局时,每个子组件都可以指定如下两个XML属性:layout_xlayout_y
 
距离单位:
px:像素。
dip/dp:设备独立像素,基于屏幕密度的抽象单位dippx的比例换算随着屏幕大小的变化而变化
sp:比例像素,主要处理字体大小
in:英寸
mm:毫米
pt:磅,标准长度单位,1/72英寸
 
xml布局文件:用户登陆
 
 
    
  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  3. android:orientation="vertical" 
  4. android:layout_width="fill_parent" 
  5. android:layout_height="fill_parent" 
  6. > 
  7.         <!-- 定义一个文本框,使用绝对定位 --> 
  8.         <TextView   
  9.         android:layout_x="20dip" 
  10.         android:layout_y="20dip" 
  11.         android:layout_width="wrap_content"   
  12.         android:layout_height="wrap_content"   
  13.         android:text="用户名:" 
  14.         /> 
  15.         <!-- 定义一个文本编辑框,使用绝对定位 --> 
  16.         <EditText   
  17.         android:layout_x="80dip" 
  18.         android:layout_y="15dip" 
  19.         android:layout_width="wrap_content"   
  20.         android:width="200px"   
  21.         android:layout_height="wrap_content"   
  22.         /> 
  23.         <!-- 定义一个文本框,使用绝对定位 --> 
  24.         <TextView   
  25.         android:layout_x="20dip" 
  26.         android:layout_y="80dip" 
  27.         android:layout_width="wrap_content"   
  28.         android:layout_height="wrap_content"   
  29.         android:text="密  码:" 
  30.         /> 
  31.         <!-- 定义一个文本编辑框,使用绝对定位 --> 
  32.         <EditText   
  33.         android:layout_x="80dip" 
  34.         android:layout_y="75dip" 
  35.         android:layout_width="wrap_content"   
  36.         android:width="200px"   
  37.         android:layout_height="wrap_content"   
  38.         android:password="true" 
  39.         /> 
  40.         <!-- 定义一个按钮,使用绝对定位 --> 
  41.         <Button   
  42.         android:layout_x="130dip" 
  43.         android:layout_y="135dip" 
  44.         android:layout_width="wrap_content"   
  45.         android:layout_height="wrap_content"   
  46.         android:text="登   录" 
  47.         /> 
  48. </AbsoluteLayout> 
  49.  
效果图: