我想在一个CoordinatorLayout
同时使用AppBarLayout
和BottomNavigationLayout
,我有隐藏BottomNavigationLayout
所要求的material guideline困难。显示/隐藏BottomNavigationView与AppBarLayout
我的意思是这样的:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_insetEdge="top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"
app:menu="@menu/menu_bottom_navigation"/>
<FrameLayout
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
正如你所看到的,我也有这是我们用来包含具有实际内容片段的FrameLayout
。目前,BottomNavigationView
没有默认/内置行为 - 既不适用于视图本身,也不适用于其兄弟姐妹。现有的appbar_scrolling_view_behavior
与appbar协同处理内容视图,但忽略其他兄弟。
我正在寻找解决方案来隐藏并显示滚动条上的appbar和底部导航视图。