[ACCEPTED]-How to manage the Blank White Loading screen of an Android Webview?-loading
You could alternatively make the webview 1 transparent:
webview.setBackgroundColor(0x00000000);
Simply put this code in onCreate
ProgressDialog _dialog ;
my_web_view.setWebViewClient(new WebViewClient(){
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
_dialog =ProgressDialog.show(Store_locator.this, "", "Please wait...");
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
_dialog.dismiss();
}
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// TODO Auto-generated method stub
super.onReceivedError(view, errorCode, description, failingUrl);
try{
_dialog.dismiss();
}catch (Exception e) {
// TODO: handle exception
}
}
});
0
the answer to this is that there's no good 11 answer. what you want, as you stated, is 10 that the webview shows the current content 9 until the new content is loaded ... just 8 like a normal browser. it won't do that.
you 7 can show loading animations, but it's still 6 not a good user experience. if you make 5 a full-screen type of animation, the user 4 is jarred with flashing screens. if you 3 make a browser-type progress at the top 2 / bottom, it looks odd because you still 1 have most of the page white.
Maybe you can take a look at this previous 1 issue.
To manage blank white screen what you can 6 do is set a proper background colour (not 5 white) to your layout xml , make the visibility 4 of the webview gone in the layout xml file 3 and add a webviewclient to it and whenever 2 the load of the URL is completed the set 1 the webview's visibility to visible.
public void onPageFinished(WebView view, String url) {
// do your stuff here
webView.setVisibility(View.VISIBLE);
}
});
webView.setBackgroundColor(Color.TRANSPARENT) removes 1 the white screen for webview
webview.setBackgroundColor(0x00000000);
Worked for me
for eg: Instead of 0x00000000
, I use 5 my color code 6424633
(Hex code - #620839
for the red 4 background
Hence when Splash screen intent 3 open Mainactivity, instead of showing white 2 blank screen, will show red background and 1 when webview load URL it will be gone.
I'm having the same problem, it was resolved 1 when I added the code below to webView.setWebViewClient.
@SuppressLint("WebViewClientOnReceivedSslError")
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed(); // Ignore SSL certificate errors
}
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.