在一个包含3个片段的Activity中,我实现了自动隐藏工具栏功能。它工作得很好,但是,我想让我的进度条不可移动(目前它在我滚动页面时上升)与adview相同。我该怎么办?
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
android:isScrollContainer="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBar3"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:max="100"
android:progressDrawable="@drawable/greenprogress"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webViewTop"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/progressBar3"/>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
我知道他们都在NestedScrollView
,但如果我在网页浏览中包含NestedScrollView
,就像这样:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progressBar3"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:max="100"
android:progressDrawable="@drawable/greenprogress"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<android.support.v4.widget.NestedScrollView
android:isScrollContainer="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webViewTop"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/progressBar3"/>
</android.support.v4.widget.NestedScrollView>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
adview似乎是静态的。并且进度完全消失(在屏幕上显示1秒然后消失)。
感谢您的帮助。
答案 0 :(得分:0)
终于解决了。创建了一个线性布局,并在其中移动了webview和进度条。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ProgressBar
android:id="@+id/progressBar3"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="3dip"
android:max="100"
android:progressDrawable="@drawable/greenprogress"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
<android.support.v4.widget.NestedScrollView
android:isScrollContainer="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="fill_vertical"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webViewTop"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/progressBar3"/>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</RelativeLayout>