Marco M Marco M - 1 year ago 147
Android Question

Android WebView Rendering Finished

I'm approching with the android development and webviews.
I want to display the webview just after the rendering has finished, so I got an ImageView visible on the top of the webview. How can i hide the ImageView ONLY after the webview has been rendered?

Answer Source

You have to enable javascript in your webview and then pass a javascript interface to webview so that you can interact with android code form javascript.

While setting up the webview add these to enable javascript and javascript interface

  webView.addJavascriptInterface(new WebAppInterface(this),

public class WebAppInterface {
    Context mContext;
    /** Instantiate the interface and set the context */
    WebAppInterface(Context c) {
        mContext = c;

    /** Hide image view */
    public void hideImageView() {

In javascript call

document.addEventListener('DOMContentLoaded', function() {
   setTimeout(function () 
 { Android.hideImageView(); }, 3000);
}, false);

Note: you need to have this javascript code in your content which you are loading in webview

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download