我正在尝试加载网页,但我希望用户看到页面加载但在页面加载之前无法与之交互。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView
android:id="@+id/mainWebview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#40606060"
/>
我只是想在上面放一个半透明的灰色层,当页面加载时我会隐藏它。我认为我需要的是某种容器内的两个 View 。这篇文章 ( Can I overlap the WebView
with an ImageButton
? ) 有一个类似的问题,但是当我使用 WebView
时,我仍然可以通过滚动与它交互。所以我一直在使用 WebView
和 LinearLayout
(我也尝试过 ImageView
)在 FrameLayout
中(我也尝试过 GridLayout
).
在这两种情况下,我都可以按需要覆盖 WebView
,但我仍然可以通过用手指滚动来与 Webview
交互,但我不希望这样。在 HTML 中,我只是将一个 DIV 放在另一个之上,它会实现这一点,但我不确定如何在 Android 中做同样的事情。
感谢您的帮助!
最佳答案
只需将您的 LinearLayout
设置为 clickeable = "true"
<LinearLayout
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#40606060"
android:clickeable="true"
/>
关于android - 如何用半透明覆盖层覆盖WebView,防止WebView被触摸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47745771/