我正在做一个项目,在其中我试图使屏幕变黑,所以我在这里使用查看属性,但按钮仍然可见(判断屏幕截图).我以为按钮是看不见的.我将处理Kotlin文件中的View属性.请帮忙解决这个问题.

xml screenshot

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.appcompat.widget.AppCompatButton
        android:id="@+id/log_in_button"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:backgroundTint="#F5931D"
        android:text="login"
        android:textAllCaps="false"
        android:textColor="@color/white"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <View
        android:id="@+id/loading_animation"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:background="@color/black"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

推荐答案

这是elevation期,你有两个 Select :

  • 通过更改代码中的可见性来完全隐藏按钮.
  • 将标高loading_animation设置为高于默认按钮标高的值.判断this link from material design以查看构件的默认高程

按钮的静止高程=2DP,因此将您的loading_animation‘S高程设置为更高,它将覆盖所有内容

android:elevation="4dp"

Android相关问答推荐

Android配置设置. gradle不同应用风格

Android可组合继承?

Jetpack Compose:如何将浮动操作按钮上方的子按钮居中对齐?

在Jetpack Compose中从LazyColumn中删除项目时发生IndexOutOf边界异常

Android-LVL库始终返回NOT_SUBLISTED

如何用帆布在喷气背包中画一个圆环?

为什么我在 android 中使用 TabLayout 时无法启动我的 Activity?

需要 java 17 而不是 java 11:Android CI-CD GitHub Actions

更改当前活动并返回后,Android webview 滚动不起作用

在 theme.xml 中使用 android:autoCompleteTextViewStyle

获取 ArithmeticException:除以零,但我没有在任何地方除以零

当包含可绘制对象的整数变量传递给 painterResource 函数时,为什么图像不在 Android Studio 中呈现?

在移动设备上看到时如何增加 PasswordField 文本?

从活动共享视图模型以使用 hilt 组合函数

重命名列失败的房间自动迁移(NOT NULL 约束失败,生成错误的迁移类)

如何在jetpack compose中创建水印文字效果

为什么官方文档用大写字母表示val变量?

协程是否在 if 条件下保持秩序?

Android WebView 没有在第一次页面完成时从本地存储读取数据?

Android:在模块 jetified-play-services-measurement 和 jetified-play-services-measurement-impl 中发现重复类