android - 如何用半透明覆盖层覆盖WebView,防止WebView被触摸?

标签 android xml webview overlap

我正在尝试加载网页,但我希望用户看到页面加载但在页面加载之前无法与之交互。

<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 时,我仍然可以通过滚动与它交互。所以我一直在使用 WebViewLinearLayout(我也尝试过 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/

相关文章:

javascript - 在Webview中从JS调用Titanium函数

java - GoogleAPIClient 已弃用 - 如何实现新的 GoogleSignInOptions?

Android、libgdx 和 box2d 基础知识

android - WebView.loadUrl(url,headers)在android中不起作用

xml - 如何在 xslt 中使用 xpath 作为变量?

java - 如何在 Java 中将 XML 转换为 JSON 并避免解析器尝试将 String 解析为数字

android - 从本地 Assets 加载时,jQuery Mobile 在 WebView 中不工作

java - datasnapshot.getvalue() 不起作用并导致应用程序崩溃

android - PendingIntent 不适用于参数

xml - 以安全的 Rust 方式切片 XML 字符串