【发布时间】:2021-06-21 20:58:41
【问题描述】:
我有一个带有垂直按钮的屏幕。没什么花哨的,但它可以完成工作。其中一个按钮是退出。在注销过程中,我想显示一个进度圈......这工作但下面的按钮仍然可以点击,我不想。出现加载屏幕时,所有按钮都不应是可点击的。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@drawable/teal_background"
android:paddingLeft="16dp"
android:paddingTop="16dp"
android:paddingRight="16dp"
android:paddingBottom="16dp">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="-16dp"
android:paddingRight="-16dp">
<ImageButton
android:id="@+id/back_button"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_weight="1"
android:adjustViewBounds="true"
android:background="@android:color/transparent"
android:padding="12dp"
android:scaleType="fitCenter"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/back" />
<LinearLayout
android:id="@+id/top_nav"
android:layout_width="match_parent"
android:layout_height="52dp"
android:gravity="center_vertical"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Settings"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
...
<Button
android:id="@+id/firebase_cloud_messaging_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/transparent_bg_bordered_button"
android:text="Firebase Cloud Messaging"/>
<Button
android:id="@+id/vehicle_signals_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/transparent_bg_bordered_button"
android:text="Vehicle Signals"/>
<Button
android:id="@+id/notifications_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/transparent_bg_bordered_button"
android:text="Notifications"/>
<Button
android:id="@+id/sign_out_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/transparent_bg_bordered_button"
android:text="Sign out"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorAccent"
android:visibility="visible"
android:clickable="false">
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_gravity="center"
android:layout_width="36dp"
android:layout_height="36dp" />
</androidx.appcompat.widget.LinearLayoutCompat>
关于如何确保加载时没有点击按钮的任何想法是visibile>
谢谢
【问题讨论】:
-
一个快速的答案就是 setVisibility = 在显示 ProgressBar 时转到那些按钮
-
button.setClicable(false)在运行时,或者尝试将andorid:clicable = "true"添加到 ProgressBar
标签: java android click progress-bar