Toolbar not hiding on RecyclerView scroll

风流意气都作罢 提交于 2019-12-05 04:18:16

If your RecyclerView is inside of a fragment try putting the following code in the root view of the fragment layout: app:layout_behavior="@string/appbar_scrolling_view_behavior". The view that contains that must be a direct child of the CoordinatorLayout

As @orrett3 described just add this line

 app:layout_behavior="@string/appbar_scrolling_view_behavior"

to your container FrameLayout like this

<FrameLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

I assumed the RecyclerView is a child of this container.

You need to do 2 actions:

  1. remove from toolbar xml this line:

    app:layout_scrollFlags="scroll|enterAlways"

  2. As other answers, add this line to layout that wrap your fragment's (in your case it's frame layout)

    app:layout_behavior="@string/appbar_scrolling_view_behavior"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!