我试图同时使用AppBarLayout
,并BottomNavigationLayout
在一个单一的CoordinatorLayout
,我有隐藏的困难BottomNavigationLayout
所要求的材料方针.
我的意思是这样的:
<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>
Run Code Online (Sandbox Code Playgroud)
如您所见,我还有一个FrameLayout
用于包含实际内容的片段.目前,没有默认/内置行为BottomNavigationView
- 既不是视图本身,也不是其兄弟姐妹.现有appbar_scrolling_view_behavior
处理与appbar协调处理内容视图但忽略其他兄弟.
我正在寻找一种隐藏的方法,并在滚动时显示appbar和底部导航视图.
android android-layout android-coordinatorlayout bottomnavigationview
我有一个应用程序,其中包含一个 Activity,多个 Fragments 模型,其中多个 Fragment 有一个 RecyclerView 来显示带有内容的卡片。我还实现了 Material Design 2.0 中的 BottomAppBar,一切都很好,除非 AppBar 阻止了 RecyclerView 中的最后一个 CardView。
在布局方面,我在一个 Fragment 内的 ConstraintLayout 中有一个 RecyclerView,它位于主要活动的 FrameLayout 中。
文档显示,要在 Scroll 上隐藏 BottomAppBar,我们需要在 NestedScrollView 中实现 RecyclerView。这里有一个关于 SO 的问题,其中的答案也说明了相同,但似乎没有实际的文档或示例来演示如何做到这一点,除了这篇关于 Medium 的文章,它在 Activity 中使用了 NestedScrollView直接,持有一个 CoordinatorLayout 持有一个 ConstraintLayout。
注意:我认为它也适用于魔法,因为在我的片段中复制布局在我的应用程序中根本没有任何影响。
我如何在这里使用 NestedScrollView?
PS:我需要有 TextView,因为我将 RecyclerView 设置为 VISIBILITY.GONE 并在没有数据可显示时将 TextView 设置为 VISIBLE。
片段布局
<android.support.constraint.ConstraintLayout 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/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.domain.APPNAME.Fragments.FragmentList">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewIncident"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="30dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" …
Run Code Online (Sandbox Code Playgroud) android android-layout android-recyclerview android-nestedscrollview android-bottomappbar
android ×2