3

In an CoordinatorLayout, a FAB is moved because its behavior class's onDependentViewChanged() is called when the Snackbar animates in or out.

However, when you call Snabackbar.dismiss() no animation takes place. And therefore no onDependentViewChanged(). And thus movement of the FAB.

Is it possible to either

  1. animate the Snackbar dismiss?
  2. create a behavior that moves the FAB when the Snackbar causes onDependentViewRemoved()?

This is arguably a duplicate of this. Yet it doesn't suggest any solutions to create the dismiss animation--but the solutions there may provide a practical solution in the meantime.

mmm111mmm
  • 3,607
  • 4
  • 27
  • 44
  • The 'best' solution I've come up with so far, is to make the FAB translate to the `CoordinatorLayout`'s bottom in `onDependentViewRemoved()`--although obviously if your FAB needs to be elsewhere this would have to change--once the `Snackbar` is removed: `float translationY = Math.min(0, coord.getBottom() - fab.getBottom()); fab.setTranslationY(translationY);` – mmm111mmm Mar 03 '16 at 01:04
  • Possible duplicate of [FloatingActionButton does not come down when dismissing Snackbar](http://stackoverflow.com/questions/32798807/floatingactionbutton-does-not-come-down-when-dismissing-snackbar) – Doug Stevenson Mar 03 '16 at 01:56
  • Yes, I'll merge it in. Although the solution is the same as the comment above, practically. – mmm111mmm Mar 03 '16 at 02:17

0 Answers0