为了账号安全,请及时绑定邮箱和手机立即绑定

进度条未显示在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 关注
  • 126 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信