2 znl 12 znl_12 于 2012.12.05 15:57 提问

在webview中如何把进度条变成进度圈

最近想在程序中设置的进度条改变成进度圈。以下是我的代码:

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

如何把进度条的格式变成圈呢?请求大家指点一二。谢谢!

2个回答

cytown
cytown   2012.12.05 17:26
已采纳

getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

yongyong_21
yongyong_21   2012.12.07 16:24
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);
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!