OPTIMIST .KZ Asked:2020-01-17 01:04:41 +0000 UTC2020-01-17 01:04:41 +0000 UTC 2020-01-17 01:04:41 +0000 UTC 如何在按下特定按钮时锁定屏幕 772 我有一个登录页面,点击“登录”按钮后,我需要暂时锁定屏幕,直到我得到服务器的响应。 java 1 个回答 Voted Best Answer Agrgg 2020-01-17T01:23:52Z2020-01-17T01:23:52Z 您可以简单地在其他所有内容之上显示带有进度条的叠加层View,但不要忘记使其可点击 ( 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> 在这个例子FrameLayout中,它是页面上所有其他元素的容器,RelativeLayoutc idprogressBarOverlay是一个半透明的覆盖层(透明度由颜色控制@color/overlay_grey)。只需在适当的时候使叠加层可见progressBarOverlay.setVisisbility(View.VISISBLE),然后将值改回View.GONE以隐藏叠加层即可。
您可以简单地在其他所有内容之上显示带有进度条的叠加层
View,但不要忘记使其可点击 (android:clickable="true"):在这个例子
FrameLayout中,它是页面上所有其他元素的容器,RelativeLayoutc idprogressBarOverlay是一个半透明的覆盖层(透明度由颜色控制@color/overlay_grey)。只需在适当的时候使叠加层可见progressBarOverlay.setVisisbility(View.VISISBLE),然后将值改回View.GONE以隐藏叠加层即可。