Android 如果我用安卓系统编写代码并在手机中运行,文本会重叠。下面是我的代码

Android 如果我用安卓系统编写代码并在手机中运行,文本会重叠。下面是我的代码,android,Android,如果我在我的手机上运行这个代码,所有文本视图和按钮都在每一圈上,我使用约束布局 <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="QUANTITY" /> <TextView android:layout_width="wrap_content" android:layout_height="

如果我在我的手机上运行这个代码,所有文本视图和按钮都在每一圈上,我使用约束布局

 <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="QUANTITY" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="0"
    />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text= "ORDER"
    />

很明显,在相对布局中有这两个文本视图和一个按钮

在RelativeLayout中,每个视图的位置必须指定为相对于同级元素的位置,如果没有指定,则所有视图都将放置在与每个视图重叠的屏幕的相同位置

您的代码应如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
 <TextView
    android:id="@+id/text1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:text="QUANTITY" />

<TextView
    android:id="@+id/text2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_below="@id/text1"
    android:text="0"
    />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:layout_below="@id/text2"
    android:text= "ORDER"
    />
</RelativeLayout>


没有父布局,没有人能够帮助您编写完整的xml,这取决于您使用的布局使用
LinearLayout
作为父布局并设置垂直方向这将解决重叠问题编辑并显示完整的xml代码。