我已经实现了滚动底部导航的隐藏功能,该功能可以正常工作,但是,当我在其顶部添加一个Adview时,滚动功能将停止工作。因此,我正在寻求有关如何解决此问题的指导/建议。我注意到这是可能的,因为我已经在其他应用程序上看到了相同的功能。
APP_BAR_MAIN
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/xxxxxxx_screen_background_color"
app:popupTheme="@style/AppTheme.PopupOverlay">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@color/xxxxxxx_screen_background_color"
android:src="@drawable/logo7" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<include
layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
CONTENT_MAIN
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_main" />
主要
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_above="@+id/navigation"
app:adSize="BANNER"
app:adUnitId="@string/test_banner_ad_unit_id" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:background="#166cba"
app:elevation="16dp"
app:layout_behavior="com.xxxxx.xxxx.Helpers.BottomNavigationViewBehavior"
app:menu="@menu/navigation" />
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>