Progress Bar For Internal Links Of A Webview In Android Studio
I have a WebView developed with Android Studio. I want to implement a progress bar to appear on every internal page of the WebView. I show you the code. Although I must clarify tha
Solution 1:
Instead of a Spinner progress bar, you can use horizontal bar by changing the style.
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"--- other attributes here ---
/>
Place this horizontal progress bar on the top of the webview similar to the image below.
Additionally, by setting chromeWebClient
to the webview and overriding onProgressChanged
method we can get the progress of the page loading which can be set to the horizontal progress bar.
webView.setWebChromeClient(new WebChromeClient() {
publicvoidonProgressChanged(WebView view, int newProgress) {
progressBar.setProgressCompat(newProgress, true)
}
});
Post a Comment for "Progress Bar For Internal Links Of A Webview In Android Studio"