簡體   English   中英

Android WebView渲染完成

[英]Android WebView Rendering Finished

我正在批准android開發和webviews。 我想在渲染完成后立即顯示Webview,因此在Webview的頂部可以看到ImageView。 渲染Web視圖后,如何僅隱藏ImageView?

您可以嘗試這樣的事情:

webView.setWebViewClient(new WebViewClient() {
  public void onPageFinished(WebView view, String url) {
    // Page is loaded!
  }
}

您必須在webview中啟用javascript,然后將javascript接口傳遞到webview,以便可以與android代碼形式的javascript進行交互。

在設置網絡視圖時,添加這些以啟用javascript和javascript界面

 webView.getSettings().setJavaScriptEnabled(true);
  webView.addJavascriptInterface(new WebAppInterface(this),
                   "Android");

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

    /** Hide image view */
    @JavascriptInterface
    public void hideImageView() {
        imageView.setVisibilty(View.GONE);
     }  
    }

在javascript通話中

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

注意:您需要在網站視圖中加載的內容中包含此javascript代碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM