When using webview to show html pages,
there will be several seconds of blank page before it finished rendering.
For better user experience, is there a way to make it show a loading image during that several seconds?
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. In the above code, we have taken web view to show html content.
The loadUrl() and loadData() methods of Android WebView class are used to load and display web page.
This interface was deprecated in API level 12. This interface is now obsolete.
Try this
...... webView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { activity.setTitle("Loading..."); activity.setProgress(progress * 100); if(progress == 100) activity.setTitle(R.string.app_name); } }); ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With