Skip to content Skip to sidebar Skip to footer

Android Webview Rendering Is Showing A White Page

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. Context co

Solution 1:

What version of Android are you testing on? Pre-4.1 versions of Android seem to have this sort problem with WebViews sometimes.

Add this to the manifest for that Activity to fix the problem:

android:hardwareAccelerated="false"

Solution 2:

Make WebView invisible in your layout:

<WebView...android:visibility="invisible".../>

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

webView.setWebViewClient(newWebViewClient() {
    @OverridepublicvoidonPageFinished(WebView view, String url) {
        if (webView.getVisibility() != View.VISIBLE) {
            webView.setVisibility(View.VISIBLE);
        }
    }
});

Solution 3:

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

publicbooleanshouldOverrideUrlLoading(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);
    returnfalse; // 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.

Post a Comment for "Android Webview Rendering Is Showing A White Page"