Android RelativeLayout z索引无法正常工作(不再)

问题描述 投票:-1回答:2

我不明白这个问题。我很确定我曾经这样做,但在这种情况下,不遵循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>

enter image description here

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

android android-relativelayout
2个回答
1
投票

请使用海拔

android:elevation="10dp"

在这里,你可以看到你的solution


0
投票

如果向“相对布局”添加任何视图,如果不使用布局对齐方式(如layout_above / layout下面的/ layout_toleftof或右侧等),它会将视图放在另一个视图上方

© www.soinside.com 2019 - 2024. All rights reserved.