Reputation: 739
I'm using a webview on my activity. page is loaded from android_asset:
webView.loadUrl("file:///android_asset/htm/main.htm");
I have onPageFinished handler to show the view once the page is loaded like this:
public void onPageFinished(WebView view, String url) {
view.setVisibility(View.VISIBLE);
the problem is when app is starting up I can see white rectangle instead of html content. in a moment it updates to real html content. how would I catch event when the page is rendered to the webview? or is there another work-around for this issue?
Upvotes: 1
Views: 1694
Reputation: 9020
I met with the same problem, but then i used onProgressChanged() function to avoid this blank screen. you can start a progress dialog in onPageStart() function and then from onProgressChanged() you will be able to know at what specific percentage the your page appears and at that, you can make your progress dialog disappear.
you may try this:
public void onProgressChanged(WebView view, int newProgress) {
Log.e("onProgressChanged", " Value is: " + newProgress);
if (newProgress >= 90) {
if (dialog != null) {
dialog.dismiss();
}
}
super.onProgressChanged(view, newProgress);
}
90 is the value in my case when page appears on screen,you may use your value ranging between 1-100.
Upvotes: 1