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 .