I have a ToolBar and Recyclerview wrapped in a Coordinatorlayout. The RecyclerView is populated with messages from our api and are stacked from the bottom. (Like a chat application)
//Set the layout manager
LinearLayoutManager layoutManager = new LinearLayoutManager(requireContext());
layoutManager.setStackFromEnd(true);
layoutManager.setReverseLayout(true);
binding.listMessages.setLayoutManager(layoutManager);
I'd like to define a custom ReverseScrollBehavior by overriding the AppBarLayout.ScrollingViewBehavior to inverse it's behavior.
So when I scroll up, the toolbar hides and when I scroll back down (to the bottom) the toolbar shows.
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_messages"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
app:stackFromEnd="true"
app:reverseLayout="true"
app:layout_behavior="com.rootsoft.kot.utils.ReverseScrollBehavior" />
I'd like to use the ScrollingViewBehavior for this rather then overriding the onTouch
UPDATE
What I'm trying to achieve is to get the inverse of the current appbar_scrolling_view_behavior. Imagine having a chat application where the newest messages are starting from the bottom. When you scroll up, I want to hide the toolbar. The current situation with the AppBarLayout is when you scroll up, the toolbar is shown and when you scroll back down, it hides.
My scrollflags are: app:layout_scrollFlags="scroll|enterAlways|snap"