Android RelativeLayout zIndex 不工作(不再)

Android RelativeLayout zIndex not working (anymore)

我不明白这个问题。我很确定我曾经这样做过,但在这种情况下,没有遵循 zindex 顺序,下面的 TextView 隐藏在按钮后面:

<?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="wrap_content">
<Button
    android:text="Button"
    android:layout_width="match_parent"
    android:layout_height="50dp" />
<TextView
    android:textColor="@color/black"
    android:text="TextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</RelativeLayout>

我已经重新启动了 Android Studio,但更糟糕的是,这在我的设备上也是一样的,所以它不是 Android Studio 错误。这到底是什么问题?

如果您向相对布局添加任何视图,如果您不使用 layout_above/layout_below/layout_leftof 或 rightof 等布局对齐方式,它会将您的视图置于另一个视图之上

请使用海拔高度

android:elevation="10dp"

在这里你可以看到你的 solution