Make a View appear via AnimatorListener - Android Animation

Android examples for Animation:Animation to Show

Description

Make a View appear via AnimatorListener

Demo Code


import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;

public class Main{
    public static ObjectAnimator appear(final View view) {
        ObjectAnimator alpha = ObjectAnimator
                .ofFloat(view, "alpha", 0f, 1f);
        alpha.setDuration(Constants.DEFAULT_DURATION);
        alpha.setInterpolator(new AccelerateDecelerateInterpolator());

        alpha.addListener(new Animator.AnimatorListener() {
            @Override//w w w  . j av  a2 s .co m
            public void onAnimationStart(Animator animator) {
                view.setVisibility(View.VISIBLE);
            }

            @Override
            public void onAnimationEnd(Animator animator) {

            }

            @Override
            public void onAnimationCancel(Animator animator) {

            }

            @Override
            public void onAnimationRepeat(Animator animator) {

            }
        });

        return alpha;
    }
}

Related Tutorials