0

I have a BottomAppBar that hides and shows when a RecyclerView is scrolled via its attribute hideOnScroll.
I would like to change the FloatingActionButton alignment mode when the BottomAppBar hides or shows.

I have not found any listeners or functions on how to achieve this. Are there any and how can I achieve this?

René Jörg Spies
  • 1,544
  • 1
  • 10
  • 29

1 Answers1

0

I have not found a listener to work with.

I achieved my wished behavior by overriding the BottomAppBar.Behavior class and its methods slideUp() and slideDown().

In those methods I just change the BottomAppBars FAB alignment mode appropriately and thats it. Now just tell the BottomAppBar to use this new behavior class via its XML attribute app:layout_behavior="MyBottomAppBarBehavior".

But I figured this is rather bad because it somewhat eats a lot of resources and wont show smoothly on lower-end or older devices. It also re-aligns the BottomAppBar's menu when you do it quickly.

So I decided to just hide the FAB when the BottomAppBar is hidden and vice versa. I achieved this similarily by overriding the FloatingActionButton.Behavior class and do stuff in there. You can find good tutorials for this online.

René Jörg Spies
  • 1,544
  • 1
  • 10
  • 29