That'sIs JustCrazy
That'sIs JustCrazy

Reputation: 143

How to cover a WebView with a semi-transparent covering layer that prevents the WebView from being touched?

I'm trying to have a webpage load but I want the user to see the page loading but be unable to interact with it until the page loads.

<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"
    />

I just thought I'd put a semi-transparent, gray layer over it which I would hide when the page has loaded. I think what I need is two views inside some sort of container. This post (Can I overlap the WebView with an ImageButton?) has a similar question but when I use a WebView I can still interact it by scrolling.So I've been using a WebView and a LinearLayout (i've tried an ImageView as well) inside a FrameLayout (I've tried a GridLayout as well).

In both cases, I can cover the WebView just like I want but I can still interact with the Webview by scrolling with my finger and I don't want that. In HTML I would just put one DIV on top of another and it would accomplish this but I'm not sure how to do the equivalent with Android.

Thanks for any help!

Upvotes: 1

Views: 313

Answers (2)

diegoveloper
diegoveloper

Reputation: 103421

Just put your LinearLayout as clickeable = "true"

<LinearLayout
    android:layout_height="fill_parent"
    android:layout_width="fill_parent"
    android:background="#40606060"
    android:clickeable="true"
    />

Upvotes: 1

Subhash Prajapati
Subhash Prajapati

Reputation: 196

You can Implement WebViewClient and extend onPageFinished() as follows:

mWebView.setWebViewClient(new WebViewClient() {

   public void onPageFinished(WebView view, String url) {
        // do your stuff here
    }
});

you can show progress dialogue when WebView start load the page and dismiss ProgressBar onPageFinished() Method.

Tell me if you have still any query...

Upvotes: 0

Related Questions