天天看点

Android布局方式(AbsoluteLayout)学习

                      AbsoluteLayout 可以让子元素指定准确的x/y坐标值,并显示在屏幕上。(0, 0)       为左上角,当向下或向右移动时,

         坐标值将变大 AbsoluteLayout 没有页边框,允许元素之间互相重叠.这种布局方式不推荐使用,刚性太强,在不同的界面上

         的效果会不同.

                代码演示:

<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    android:background="@color/bgcolor" >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户名:"
        android:textColor="@color/white"
        android:textSize="22sp"
        android:type
        android:layout_x="40dip"
        android:layout_y="60dip"
         />
    <EditText 
        android:width="160dip"
        android:height="35dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="120dip"
        android:layout_y="60dip"
       
        android:textColor="@color/gray"
        android:scrollHorizontally="false"
        android:background="@color/white"/>
     <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="密  码:"
        android:textColor="@color/white"
        android:textSize="22sp"
        android:type
        android:layout_x="40dip"
        android:layout_y="100dip"
         />
      <EditText 
        android:width="160dip"
        android:height="35dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="120dip"
        android:layout_y="100dip"
        android:password="true"
        android:textColor="@color/gray"
        android:scrollHorizontally="false"
        android:background="@color/white"/>
      
      <Button 
          android:text="登录"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:layout_x="130dip"
          android:layout_y="140dip"/>
      <Button 
          android:text="注册"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:layout_x="200dip"
          android:layout_y="140dip"/>
   
   

</AbsoluteLayout>
           

      截图:

Android布局方式(AbsoluteLayout)学习