library/src/main/java/de/mrapp/android/view/FloatingActionButton.java
private void animateVisibility(final int visibility, final long duration) {
        if (visibilityAnimator != null) {
            visibilityAnimator.cancel();
        }

        AnimatorListener listener = createVisibilityAnimatorListener(visibility);
        float targetScale = visibility == View.VISIBLE ? 1 : 0;
        long animationDuration = Math.round(Math.abs(getScaleX() - targetScale) * duration);
        Interpolator interpolator = new AccelerateDecelerateInterpolator();
        visibilityAnimator =
                animate().setInterpolator(interpolator).scaleX(targetScale).scaleY(targetScale)
                        .setDuration(animationDuration).setListener(listener);
    }
private void animateVisibility(final int visibility, final long duration) {
        if (visibilityAnimator != null) {
            visibilityAnimator.cancel();
        }

        AnimatorListener listener = createVisibilityAnimatorListener(visibility);
        float targetScale = visibility == View.VISIBLE ? 1 : 0;
        long animationDuration = Math.round(Math.abs(getScaleX() - targetScale) * duration);
        Interpolator interpolator = new AccelerateDecelerateInterpolator();
        visibilityAnimator =
                animate().setInterpolator(interpolator).scaleX(targetScale).scaleY(targetScale)
                        .setDuration(animationDuration).setListener(listener);
    }
Animates changing the visibility of the floating action button.

@param visibility
The visibility, which should be set, as an {@link Integer} value. The visibility may
be <code>View.VISIBLE</code>, <code>View.INVISIBLE</code> or <code>View.GONE</code>
@param duration
The duration of the animation in milliseconds as a {@link Long} value