开发者

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

开发者 https://www.devze.com 2023-02-03 19:21 出处:网络
This is my code : getWindow().requestFeature(Window.FEATURE_PROGRESS); WebView mWebView = (WebView) findViewById(R.id.mywebview);

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..."开发者_如何学JAVA);
             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?


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);


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

精彩评论

暂无评论...
验证码 换一张
取 消