I have a login page, after clicking the "Login" button, I need to temporarily lock the screen until I receive a response from the server.

    1 answer 1

    You can simply display the overlay with the progress indicator on top of all other View , most importantly, do not forget to make it clickable ( android:clickable="true" ):

     <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" /> <RelativeLayout android:id="@+id/progressBarOverlay" android:visibility="gone" android:clickable="true" android:background="@color/overlay_grey" android:layout_width="match_parent" android:layout_height="match_parent"> <ProgressBar android:id="@+id/progressBar" android:indeterminate="true" android:layout_centerInParent="true" android:layout_width="wrap_content" android:layout_height="wrap_content" /> </RelativeLayout> </RelativeLayout> 

    In this example, FrameLayout is the container of all other elements on the page, and RelativeLayout with id progressBarOverlay is a translucent overlay (transparency is adjusted by the color @color/overlay_grey ). At the right moment, just make the overlay visible to progressBarOverlay.setVisisbility(View.VISISBLE) , and then change the value back to View.GONE to remove the overlay.

    • Thank you for what I was looking for! - OPTIMIST .KZ