RelativeLayout 布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:background="#ddf4e9"
    tools:context="com.example.administrator.jreduch01.RelativeActivity">
  <TextView
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
       android:text="腾讯QQ"
      android:textSize="40sp"
      android:gravity="center"
      android:background="#efeeee"
      android:id="@+id/tv1"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="10dp"
        android:background="#d6d3d3"
        android:id="@+id/tv2"
        android:layout_below="@id/tv1"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/tv3"
            android:layout_marginTop="40dp"
            android:text="QQ登录"
            android:textSize="30sp"
            android:drawableLeft="@mipmap/ic_launcher"
            android:layout_below="@id/tv2"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="亿万用户已经登录使用"
            android:layout_marginTop="80dp"
            android:layout_marginLeft="60dp"
            android:id="@+id/tv4"
            android:layout_below="@id/tv2"
            android:layout_toRightOf="@id/tv3"


            />


    <EditText
        android:layout_width="350dp"
        android:layout_height="50dp"
        android:hint="QQ账号/邮箱/手机号"
        android:background="#ffffff"
        android:textColor="#f0f1f0"
        android:textSize="30sp"
        android:layout_marginTop="20dp"
       android:layout_marginLeft="20dp"
        android:id="@+id/et1"
        android:layout_below="@id/tv3"/>
    <EditText
        android:layout_width="350dp"
        android:layout_height="50dp"
        android:hint="QQ密码"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="20dp"
        android:background="#ffffff"
        android:textColor="#f0f1f0"
        android:textSize="30sp"
        android:id="@+id/et2"

        android:layout_below="@id/et1"/>

    <Button
        android:layout_width="300dp"
        android:layout_height="50dp"
        android:text="登录"
        android:id="@+id/button"
        android:textColor="#f7f9f8"
        android:background="@drawable/login_bg"
        android:textSize="30sp"
        android:layout_marginTop="40dp"
        android:layout_centerHorizontal="true"
        android:layout_below="@id/et2"

       />
</RelativeLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
RelativeLayout(相对布局)是Android中一种常用的布局方式,允许您根据其他视图的位置和关系来放置视图。以下是使用RelativeLayout布局的基本步骤: 1. 在XML布局文件中,将根布局设置为RelativeLayout,例如: ```xml <RelativeLayout 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"> <!-- 在这里添加其他视图 --> </RelativeLayout> ``` 2. 在RelativeLayout中添加其他视图。您可以使用以下属性来定义视图之间的相对位置和关系: - `android:layout_alignParentTop`:将视图与父布局的顶部对齐。 - `android:layout_alignParentBottom`:将视图与父布局的底部对齐。 - `android:layout_alignParentLeft`:将视图与父布局的左侧对齐。 - `android:layout_alignParentRight`:将视图与父布局的右侧对齐。 - `android:layout_alignTop`:将视图的顶部与另一个视图的顶部对齐。 - `android:layout_alignBottom`:将视图的底部与另一个视图的底部对齐。 - `android:layout_alignLeft`:将视图的左侧与另一个视图的左侧对齐。 - `android:layout_alignRight`:将视图的右侧与另一个视图的右侧对齐。 `android:layout_below`:将视图放置在另一个视图的下方。 - `android:layout_above`:将视图放置在另一个视图的上方。 - `android:layout_toLeftOf`:将视图放置在另一个视图的左侧。 - `android:layout_toRightOf`:将视图放置在另一个视图的右侧。 通过使用这些属性,您可以根据需要调整视图的位置和关系。 这只是RelativeLayout布局的基本介绍,您可以根据实际需要进一步了解和使用其他属性和功能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值