pensilhijau
pensilhijau

Reputation: 193

Can I change the progress bar in a webview to a progress circle?

This is my code :

getWindow().requestFeature(Window.FEATURE_PROGRESS);

WebView mWebView = (WebView) findViewById(R.id.mywebview);

mWebView.getSettings().setJavaScriptEnabled(true);

final Activity activity = this;

mWebView.setWebChromeClient(new WebChromeClient(){

     public void onProgressChanged(WebView view, int progress) {
             activity.setTitle("Loading...");
             activity.setProgress(progress * 100);
                if(progress == 100)
                   activity.setTitle("My title");
             }
});

mWebView.loadUrl(URL);

I want to change the progress style to a circle.

How to change it?

Upvotes: 0

Views: 2157

Answers (2)

Li Che
Li Che

Reputation: 737

getWindow().setFeatureInt( Window.FEATUREPROGRESS, Window.PROGRESSVISIBILITY_ON);

Upvotes: 0

Kavi
Kavi

Reputation: 3880

This should do it:

getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS); // Request progress circle
setProgressBarIndeterminateVisibility(true); // Show progress circle

WebView mWebView = (WebView) findViewById(R.id.mywebview);

mWebView.getSettings().setJavaScriptEnabled(true);

final Activity activity = this;

mWebView.setWebChromeClient(new WebChromeClient(){

     public void onProgressChanged(WebView view, int progress) {
             activity.setTitle("Loading...");
             activity.setProgress(progress * 100);
                if(progress == 100)
                   setProgressBarIndeterminateVisibility(false); // Hide progress circle when page loaded
                   activity.setTitle("My title");
             }
});

mWebView.loadUrl(URL);

Upvotes: 3

Related Questions