Code example for ViewPropertyAnimator

Methods: alpha, scaleX, scaleY, setDuration, setInterpolator, setListener

0
    /** Creates the open/close animation */ 
    private void animateScale(boolean isExitAnimation, final Runnable onAnimationEndRunnable) {
        mChild.setPivotX(mTargetScreen.centerX() - mChild.getLeft());
        mChild.setPivotY(mTargetScreen.centerY() - mChild.getTop());
        ViewPropertyAnimator animator = mChild.animate();
        animator.setDuration(mAnimationDuration);
        final int scaleInterpolator = isExitAnimation ? android.R.interpolator.accelerate_quint
                : android.R.interpolator.decelerate_quint;
        animator.setInterpolator(AnimationUtils.loadInterpolator(getContext(), scaleInterpolator));
        final float scaleTarget = isExitAnimation ? 0.5f : 1.0f;
        animator.scaleX(scaleTarget);
        animator.scaleY(scaleTarget);
        animator.alpha(isExitAnimation ? 0.0f : 1.0f);
 
        if (onAnimationEndRunnable != null) {
            animator.setListener(new AnimatorListener() {
                @Override 
                public void onAnimationStart(Animator animation) {}
 
                @Override 
                public void onAnimationRepeat(Animator animation) {}