Android examples for Animation:Animation to Hide
Make a View disappear via AnimatorListener
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 disappear(final View view) { ObjectAnimator alpha = ObjectAnimator .ofFloat(view, "alpha", 1f, 0f); alpha.setDuration(Constants.DEFAULT_DURATION); alpha.setInterpolator(new AccelerateDecelerateInterpolator()); alpha.addListener(new Animator.AnimatorListener() { @Override//from w w w. j ava 2s .c om public void onAnimationStart(Animator animator) { } @Override public void onAnimationEnd(Animator animator) { view.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animator) { view.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animator animator) { } }); return alpha; } }