全国免费服务热线:

18982081108
✕

成都弹性云服务器,成都高防云服务器,互联网数据服务,成都祈钰瑶

使用AndroidWebView怎么实现顶部进度条

这篇文章给大家介绍使用AndroidWebView怎么实现顶部进度条,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

创新互联服务项目包括成武网站建设、成武网站制作、成武网页制作以及成武网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,成武网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到成武省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

布局:

<RelativeLayout  android:layout_width="match_parent"  android:layout_height="match_parent"  android:orientation="vertical">  <WebView   android:id="@+id/webView"   android:layout_width="match_parent"   android:layout_height="match_parent"   android:layout_below="@+id/toolbar_container" />  <ProgressBar   android:id="@+id/progressBar"      android:layout_width="match_parent"   android:layout_height="3dp"   android:layout_below="@+id/toolbar_container"   android:background="@drawable/crowd_progressbar_unselect" /></RelativeLayout>

进度条样式:

<style name="crowd_item_progressBar">  <item name="android:indeterminateOnly">false</item>  <item name="android:progressDrawable">@drawable/crowd_progressbar_background</item>  <item name="android:minHeight">10dp</item>  <item name="android:maxHeight">10dp</item></style>

进度图片:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item  android:id="@android:id/progress" >  <clip>   <shape>    <solid android:color="@color/selected"/>    <!--<corners android:radius="1.5dp"/>-->   </shape>  </clip> </item></layer-list>

代码:

public class WebChromeClient extends android.webkit.WebChromeClient {  @Override  public void onProgressChanged(WebView view, int newProgress) {   if (newProgress == 100) {    mProgressBar.setVisibility(GONE);   } else {    if (mProgressBar.getVisibility() == GONE)     mProgressBar.setVisibility(VISIBLE);    mProgressBar.setProgress(newProgress);   }   super.onProgressChanged(view, newProgress);  } } @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) {  LayoutParams lp = (LayoutParams) mProgressBar.getLayoutParams();  lp.x = l;  lp.y = t;  mProgressBar.setLayoutParams(lp);  super.onScrollChanged(l, t, oldl, oldt); }}

关于使用AndroidWebView怎么实现顶部进度条就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。