android webview rendering is showing a White Page

前端 未结 3 1680
天命终不由人
天命终不由人 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:44

    I'am not sure, I don't have the whole code, but I think is related to the webViewClient implemented in this function:

    public boolean shouldOverrideUrlLoading(WebView view, String url){
        // do your handling codes here, which url is the requested url
        // probably you need to open that url rather than redirect:
        view.loadUrl(url);
        view.setVisibility(View.VISIBLE);
        return false; // then it is not handled by default action
    }
    

    here is the officiel definition:

    public boolean shouldOverrideUrlLoading (WebView view, String url)

    Try to test with your code without implementing shouldOverrideUrlLoading, or make it return true.

提交回复
热议问题