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:typeface="monospace"
        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:typeface="monospace"
        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>
      截图:


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值