shellbot
shellbot

Reputation: 53

Hide content in android-webview without onPageFinished()

I have a website and I am linking it to my application. I don't want my logo to be displayed twice in webview from website since my app is already desplaying it. I've searched on stackoverflow everywhere it is recommended to use onPageFinished(). I want to know is there any other way by which i dont have to wait for page to finish loading and i can right away hide the logo part? Thank you for your suggestions.

Upvotes: 1

Views: 334

Answers (1)

Logan
Logan

Reputation: 23

Instead of overriding WebViewClient's onPageFinished, you can override WebChromeClient's onProgressChanged and suppress the logo there:

webView.setWebChromeClient(new WebChromeClient() {
    @Override
    public void onProgressChanged(WebView view, int newProgress) {
        view.loadUrl("javascript:(function() { " +
            //if element exists, hide element
            "})()");
    }
});

Note that this method will run a number of times. It's an inelegant solution but is the best alternative to onPageFinished that I've found.

Upvotes: 1

Related Questions