Reputation: 1600
I have a button, onclick of that button a webview load a html from asset, it takes a while to load that html page, so in between a while color appears, in short words while switching to webview white color comes in background, i researched a lot but not got any thing.
How to fix ??? Kindly help.
Upvotes: 3
Views: 2508
Reputation: 13548
Try to set the background color to the WebView
:
webview.setBackgroundColor(0x01000000);
EDIT: if you want a black color:
webview.setBackgroundColor(0xFF000000);
If this doesn't work for you, I suggest you this workaround:
WebView
inside a container (like a FrameLayout
) and the set the background of
the container to blackWebView
INVISIBLE when you need to load a new pageWebViewClient
to the your WebView using setWebViewClient(). Your custom WebViewClient will set the WebView visible again when the page is loaded. During the load process, you will see a black background. webView.setWebViewClient(new InternalWebViewClient()); //... private class InternalWebViewClient extends WebViewClient { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished( view, url ); webView.setVisibility(View.VISIBLE); } }
Upvotes: 4