Android相对布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@mipmap/background_login">

//1、先调大概的位置2、再调具体的位置3、最后调控件的形状比例
    <androidx.appcompat.widget.AppCompatImageView
        android:id="@+id/button_login"
        android:layout_width="36dp"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"//到布局的底部,一定要先摆好大概位置先
        android:layout_centerHorizontal="true"//然后放在水平的中央
        android:layout_marginBottom="82dp"//搞好大概位置后再开始细调,距离底下82dp
        android:background="@color/transparent"//这个是imagebutton,去掉button的背景,然后只剩下图片
        android:scaleType="fitXY"//将原图进行缩放,xy方向
        android:adjustViewBounds="true"//保持宽高比。上面这句话和这句话的意思就是按比例缩放
        android:src="@mipmap/login"//图片
        />

</RelativeLayout>

在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:orientation="vertical">

    <EditText
        android:id="@+id/edittext1"
        android:layout_width="match_parent"
        android:layout_height="46dp"
        android:layout_alignParentTop="true"//大概在布局的上面
        android:layout_marginTop="92dp"//设置上边距离
        android:layout_marginLeft="35dp"//设置左边距离
        android:layout_marginRight="35dp"//设置右边距离,因为宽度是最大屏幕的,所以设置左边右边的距离就是在设置两边的间隙
        android:background="@drawable/yuanxing"//设置背景样式,样式有颜色和圆角
        android:hint="请输入账号"//文字
        android:textSize="16sp" />//文字大小

    <EditText
        android:id="@+id/edittext2"
        android:layout_width="match_parent"
        android:layout_height="46dp"
        android:layout_below="@+id/edittext1"//大概位置在账号框的下面
        android:layout_alignLeft="@+id/edittext1"//左边和账号框对齐
        android:layout_marginTop="10dp"//上面那句设置了相对位置,因此这个距离上边的距离就是相对账号框的距离
        android:layout_alignRight="@+id/edittext1"//右边跟账号框对齐
        android:background="@drawable/yuanxing"//设置背景颜色和圆角
        android:hint="请输入密码"//文字
        android:textSize="16sp"//文字大小
        />

    <Button
        android:id="@+id/register_button"
        android:layout_width="match_parent"
        android:layout_height="46dp"
        android:layout_below="@+id/edittext2"//大概位置就是密码框的下面
        android:layout_alignLeft="@+id/edittext1"//左边和账号框的左边对其
        android:layout_marginTop="10dp"//相对密码框的下面的距离
        android:layout_alignRight="@+id/edittext1"//右边跟账号框对齐
        android:background="@drawable/test"//设置颜色和圆角
        android:text="登陆"//文字
        android:textSize="16sp"//文字大小 />

</RelativeLayout>

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值