亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

進度條未顯示在WebView的Relativelayout中

進度條未顯示在WebView的Relativelayout中

大話西游666 2021-04-05 14:15:34
我正在開發一個包含webview的應用程序。我有RelativeLayoutxml文件的根元素。的RelativeLayout已ProgressBar,SwipeRefreshLayout,WebView和AdView包含元素。默認情況下,的可見性ProgressBar設置為gone,它應該在加載網頁時出現,并且再次不可見。但是,它沒有顯示任何時間。這是我的activity_web_view.xml<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context="net.softglobe.allmedia.Showsite"    android:orientation="vertical"><ProgressBar    android:id="@+id/pb"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:progressDrawable="@drawable/progressbar_states"    style="@style/Widget.AppCompat.ProgressBar.Horizontal"    android:visibility="gone"/><android.support.v4.widget.SwipeRefreshLayout    xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/swiperefresh"    android:layout_width="match_parent"    android:layout_height="match_parent">    <WebView        android:id="@+id/webview"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:configChanges="orientation|screenSize"/></android.support.v4.widget.SwipeRefreshLayout>        <com.google.android.gms.ads.AdView            xmlns:ads="http://schemas.android.com/apk/res-auto"            android:id="@+id/adView"            android:layout_width="match_parent"            android:layout_height="wrap_content"            ads:adSize="SMART_BANNER"            android:layout_alignBottom="@id/swiperefresh"            ads:adUnitId="ca-app-pub-3940256099942544/6300978111">        </com.google.android.gms.ads.AdView>我嘗試使用LinearLayoutwithweight和weightsum屬性,然后ProgressBar顯示,但是AdView消失了。
查看完整描述

2 回答

?
拉風的咖菲貓

TA貢獻1995條經驗 獲得超2個贊

您的SwipeRefreshLayout位于ProgressBar的頂部,因此,即使使您的ProgressBar可見,它也將顯示在SwipeRefreshLayout下,并且您將無法看到它,您可以使用

 `android:layout_below="@+id/pb"`

在您的SwipeRefreshLayout中,也可以在進度條可見時將SwipeRefreshLayout可見性設置為走,而在ProgressBar不可見時將SwipeRefreshLayout可見性設置為不可見。


查看完整回答
反對 回復 2021-04-21
?
陪伴而非守候

TA貢獻1757條經驗 獲得超8個贊

覆蓋這兩個功能如下


 @Override

            public void onPageStarted(String url, Bitmap favicon) {

                pb.setVisibility(View.VISIBLE);


            }


            @Override

            public void onPageFinished(String url) {

                pb.setVisibility(View.GONE);


            }


查看完整回答
反對 回復 2021-04-21
  • 2 回答
  • 0 關注
  • 144 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號