How to animate FloatingActionButton of new Design Support Library

Michael picture Michael · May 31, 2015 · Viewed 21k times · Source

I am using a TabLayout with 5 different fragments. On 3 of these fragments a android.support.design.widget.FloatingActionButton should appear. Right now I simply set the visibility of the FAB when the tab changes, but I would like to have an animation, where the FAB comes in and out. How can I achieve this in Android?

Answer

Luci picture Luci · Aug 16, 2015

The hide/show animation for shrink/pop are automatically handled by the new version of the Support Library.(22.2.1) Then OnTabChange listener show or hide the floating action button using show/hide methods provided by the new library.

fab.show(); or fab.hide();