基本布局----AbsoluteLayout(绝对布局)

由开发人员控制,通过坐标来定位。每个子组件都可以通过layout_xlayout_y来指定X,Y坐标。
登录界面:

<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:layout_x="20dp"
        android:layout_y="20dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户名:"
        android:textColor="#000"
        android:hint="请输入用户名"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <EditText
        android:layout_x="80dp"
        android:layout_y="15dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="200px" />
    <TextView
        android:layout_x="20dp"
        android:layout_y="80dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000"
        android:text="密 码"/>
    <EditText
        android:layout_x="80dp"
        android:layout_y="75dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="200px"
        android:password="true"/>
    <Button
        android:layout_x="130dp"
        android:layout_y="135dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="登 录"/>
</AbsoluteLayout>

在这里插入图片描述

  • px:像素,每个px代表屏幕上的一个点
  • dip或dp:设备独立像素,一种基于屏幕密度的抽象单位,在每英寸160点的显示器上,1dp=1px。但随着屏幕密度的改变,dp与px的换算会发生改变。
  • sp:比例像素,主要处理字体的大小,可以根据用户的字体大小首选项进行缩放。
  • in:英寸,标准长度单位
  • mm:毫米,标准长度单位
  • pt:磅,标准长度单位,1/72英寸
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值