我有一个 RelativeLayout 作为父布局。在其中我有两个按钮和一个 FrameLayout。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="button 1"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="button 2"
android:layout_below="@+id/button1"/>
<FrameLayout
android:background="@color/blue"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
FrameLayout 具有 match_parent 的宽度和高度,但我不明白为什么它没有覆盖按钮。
如何覆盖按钮?
最佳答案
按钮似乎有一个名为 stateListAnimator 的属性。
所以你要做的是为 Lollipop 或更高版本制作另一个布局文件 (v21),并将其添加到你的按钮 xml 中:
android:stateListAnimator="@null"
对于较低版本的 Android,它似乎是这样工作的:
android:stateListAnimator="@null"
tools:ignore="UnusedAttribute"
关于android - 如何隐藏布局下的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49007534/