FloatingActionButton
                                
                                
                                
                                    FloatingActionButton copied to clipboard
                            
                            
                            
                        Support GONE instead of INVISIBLE
Sometimes you'll want the FAB to be GONE from the layout after animating. Maybe make INVISIBLE default and add an option to make it use GONE instead?
Thanks, Dan
FAB it's an ImageButton. Have you tried just to set its visibility to GONE? Like this: FloatingActionButton.setVisibility(GONE).
Of course it works, but it will not play the animation :( currently I'm using this:
    private void hideFab(final FloatingActionButton fab) {
        fab.hide(true);
        fab.setVisibility(GONE);
    }
It's a "patch" and still not perfect because itt makes the Button GONE before animation finishes.
I found out this also happening when using fab.hide(true)
Without .setVisibility(GONE). it doesn't wait for the animation to finish.
I'm currently using:
    private void hideFab(final FloatingActionButton fab) {
        fab.hide(true);
        fab.getAnimation().setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
            }
            @Override
            public void onAnimationEnd(Animation animation) {
                fab.setVisibility(GONE);
            }
            @Override
            public void onAnimationRepeat(Animation animation) {
            }
        });
    }
    private void showFab(final FloatingActionButton fab) {
        fab.setVisibility(INVISIBLE);
        fab.show(true);
    }
I'll make a fix for that an add a pull request :)
You can use your own animation and, in that case, the AnimationListener should work.
Yes I am setting my own animation using
 app:fab_showAnimation="@anim/fab_scale_up"
 app:fab_hideAnimation="@anim/fab_scale_down"
But still the "patch" function I have is not the best approach, it will be better to have this support in the library, don't you think ?
If so let me know and I'll implement it.
I have the same problem. Can't hide FloatingActionButton inside FloatingActionMenu during close animation.
If i try to add AnimationListener to Menù animation i get:
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.animation.Animation.setAnimationListener(android.view.animation.Animation$AnimationListener)' on a null object reference.
fabMenu.getAnimation() return a null object, also if i set in XML layout the animations:
 app:fab_showAnimation="@anim/fab_scale_up" app:fab_hideAnimation="@anim/fab_scale_down"
Please help