RelativeLayout (Android Studio) 有问题

Having problems with RelativeLayout (Android Studio)

我是 android 工作室和应用程序设计的新手,我在设计应用程序时遇到了一些问题。

我正在使用相对布局来设置页面上不同元素的位置,但它不起作用。我在下面包含了我的语法和结果供您参考。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Quiz app"
        android:textSize="40dp"
        tools:layout_centerHorizontal="true" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Name: "
        android:textSize="20dp"
        tools:layout_below="@id/textView1"
        tools:layout_alignParentLeft="true"
        tools:layout_marginLeft="15dp"
        tools:layout_marginTop="40dp"
        />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Password: "
        android:textSize="20dp"
        tools:layout_below="@id/textView2"
        tools:layout_alignParentLeft="true"
        tools:layout_marginLeft="15dp"
        tools:layout_marginTop="15dp"/>

    <EditText
        android:id="@+id/fillblank1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPersonName"
        android:text="name"
        android:textSize="20dp"
        tools:layout_below="@id/textView1"
        tools:layout_toRightOf="@id/textView2"
        tools:layout_marginLeft="50dp"
        tools:layout_marginTop="30dp"/>
</RelativeLayout>

但结果如下:

设备:Nexus 6P API 27 Oreo

我确实检查了与相对布局问题相关的其他问题,但我认为它们没有这种情况那么糟糕,所以我将其作为一个单独的问题提出。

tools替换为android

'tools' 命名空间仅在设计时使用,在运行时不使用。您可以阅读更多相关信息 here

例如,而不是

tools:layout_centerHorizontal="true"

android:layout_centerHorizontal="true"