項(xiàng)目中用到WebView加上進(jìn)度條放在頂部,讓用戶(hù)知道加載進(jìn)度情況,可以提高用戶(hù)體驗(yàn):
十余年品牌的成都網(wǎng)站建設(shè)公司,超過(guò)千家企業(yè)網(wǎng)站設(shè)計(jì)經(jīng)驗(yàn).價(jià)格合理,可準(zhǔn)確把握網(wǎng)頁(yè)設(shè)計(jì)訴求.提供定制網(wǎng)站建設(shè)、購(gòu)物商城網(wǎng)站建設(shè)、微信小程序、響應(yīng)式網(wǎng)站開(kāi)發(fā)等服務(wù),我們?cè)O(shè)計(jì)的作品屢獲殊榮,是您值得信賴(lài)的專(zhuān)業(yè)網(wǎng)站設(shè)計(jì)公司。
效果:

布局:
<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>
進(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);
}
}以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
當(dāng)前題目:AndroidWebView實(shí)現(xiàn)頂部進(jìn)度條
轉(zhuǎn)載注明:http://chinadenli.net/article46/gospeg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動(dòng)態(tài)網(wǎng)站、服務(wù)器托管、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)站營(yíng)銷(xiāo)、App開(kāi)發(fā)、定制開(kāi)發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)