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 simpl
The easiest way is to extend the FloatingActionButton class and override setVisibility. Like this:
public void setVisibility(final int visibility) {
if (getVisibility() != View.VISIBLE && visibility == View.VISIBLE && inAnim != null) {
animator = // create your animator here
super.setVisibility(visibility);
} else if (getVisibility() == View.VISIBLE && visibility != View.VISIBLE) {
AnimatorListenerAdapter listener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
Button.super.setVisibility(visibility);
}
});
animator = // create your animator here
animator.addListener(listener);
}
}
The code above is taken from the Button class from my library. You can find sample implementations in sources.