How to disable user interaction while ProgressBar is visible in android?

后端 未结 7 2043
我在风中等你
我在风中等你 2020-12-12 13:08

I am using a custom ProgressBar. Now while a task is going on, I am showing the progress bar, but user can still interact with the views and controls. How do I disable the

相关标签:
7条回答
  • 2020-12-12 13:39

    I have fixed this issue by adding root layout to the ProgressBar.

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:clickable="true"
        android:gravity="center"
        android:visibility="gone"
        android:id="@+id/progress">
        <ProgressBar
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:indeterminate="true"
            android:indeterminateTintMode="src_atop"
            android:indeterminateTint="@color/primary"/>
    </LinearLayout>
    

    Made the root layout clickable

    android:clickable="true"
    

    NOTE: In my main view, I had RelativeLayout as root and have added above-mentioned code inside the root layout at the last position (last child).

    Hope this helps!!

    0 讨论(0)
提交回复
热议问题