进度条未显示在WebView的Relativelayout中

我正在开发一个包含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消失了。


大话西游666
浏览 127回答 2
2回答

拉风的咖菲猫

您的SwipeRefreshLayout位于ProgressBar的顶部,因此,即使使您的ProgressBar可见,它也将显示在SwipeRefreshLayout下,并且您将无法看到它,您可以使用&nbsp;`android:layout_below="@+id/pb"`在您的SwipeRefreshLayout中,也可以在进度条可见时将SwipeRefreshLayout可见性设置为走,而在ProgressBar不可见时将SwipeRefreshLayout可见性设置为不可见。

陪伴而非守候

覆盖这两个功能如下&nbsp;@Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onPageStarted(String url, Bitmap favicon) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pb.setVisibility(View.VISIBLE);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; public void onPageFinished(String url) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pb.setVisibility(View.GONE);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java