android webview rendering is showing a White Page

前端 未结 3 1676
天命终不由人
天命终不由人 2021-02-04 22:31

Sometimes, when I load my webview with loadUrl, the website is not showing up until I touch the screen or scroll.

It\'s like I have a webview drawing problem.

         


        
3条回答
  •  无人及你
    2021-02-04 22:55

    Make WebView invisible in your layout:

    
    

    Now, show it back when onPageFinished occurs for the fist time:

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            if (webView.getVisibility() != View.VISIBLE) {
                webView.setVisibility(View.VISIBLE);
            }
        }
    });
    

提交回复
热议问题