android webview添加自定义progressbar

/res/drawable下添加progress_style.xml

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
 3     <item android:id="@android:id/background">
 4         <shape>
 5             <gradient android:startColor="#eeee" android:endColor="#eeee" />
 6         </shape>
 7     </item>
 8     <item android:id="@android:id/progress">
 9         <clip>
10             <shape>
11                 <gradient android:startColor="#0000ff" android:endColor="#0000ff" android:centerColor="#0000ff" />
12             </shape>
13         </clip>
14     </item>
15 </layer-list>

 

布局文件中添加progressbar

1 <ProgressBar
2             android:id="@+id/progressBar1"
3             style="?android:attr/progressBarStyleHorizontal"
4             android:layout_width="match_parent"
5             android:layout_height="3dp"
6             android:progressDrawable="@drawable/progress_style" />

 

view.setWebChromeClient(new WebChromeClient() {

            @Override
            public void onProgressChanged(WebView view, int position) {
                mypProgressBar.setProgress(position);
                if (position == 100) {
                    progressBarLayout.setVisibility(View.GONE);
                }
                super.onProgressChanged(view, position);
            }

        });
posted @ 2012-11-15 15:45  mr.coke  阅读(2042)  评论(0编辑  收藏  举报