最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android WebView實(shí)現(xiàn)頂部進(jìn)度條

 更新時間:2019年11月29日 10:03:44   作者:Android格調(diào)小窩  
這篇文章主要為大家詳細(xì)介紹了Android WebView實(shí)現(xiàn)頂部進(jìn)度條,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

項(xiàng)目中用到WebView加上進(jìn)度條放在頂部,讓用戶知道加載進(jìn)度情況,可以提高用戶體驗(yàn):

效果:

布局:

<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"
   style="@style/crowd_item_progressBar"
   android:layout_width="match_parent"
   android:layout_height="3dp"
   android:layout_below="@+id/toolbar_container"
   android:background="@drawable/crowd_progressbar_unselect" />

</RelativeLayout>

進(jìn)度條樣式:

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

進(jìn)度圖片:

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

 }

}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

白河县| 景泰县| 吴川市| 定远县| 漯河市| 仁布县| 乐业县| 贵阳市| 辉县市| 长葛市| 屏边| 申扎县| 宁乡县| 安图县| 台中市| 濮阳县| 汉中市| 枝江市| 县级市| 洛扎县| 罗城| 孝义市| 浑源县| 抚远县| 卫辉市| 浏阳市| 分宜县| 乌拉特前旗| 惠州市| 丽江市| 洛隆县| 太湖县| 井陉县| 比如县| 普陀区| 报价| 阳城县| 平塘县| 鄂托克前旗| 玛纳斯县| 津南区|