How to manage the Blank White Loading screen of an Android Webview?
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
}
}
});
the answer to this is that there's no good answer. what you want, as you stated, is that the webview shows the current content until the new content is loaded ... just like a normal browser. it won't do that.
you can show loading animations, but it's still not a good user experience. if you make a full-screen type of animation, the user is jarred with flashing screens. if you make a browser-type progress at the top / bottom, it looks odd because you still have most of the page white.
You could alternatively make the webview transparent:
webview.setBackgroundColor(0x00000000);