android - 如何隐藏布局下的按钮

标签 android button layout cover

我有一个 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>

screenshot

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/

相关文章:

Android - Gradle : error: package does not exist

java - 将包含键值对的对象作为值传递给 Java/Android 中的 HashMap

android - 使用 GSON 解析 JSON 日期

android - 使用新 key 在 Android Studio 中签署 Eclipse 应用程序?

Android - 图像按钮大小

android - 使单个按钮宽度以编程方式填充父级

将 Container 作为子项的 Flutter InkWell 未显示效果

CSS:如何使用背景图像和由图标分隔的居中条目正确设置水平菜单栏的样式

java - 在设置布局之外添加元素(即 JLabels)

javascript - 仅当div高于一定高度时才在div底部显示 "expand"按钮