Android examples for Animation:Animation to Hide
invisible View By Alpha Animation
import android.view.View; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.CycleInterpolator; import android.view.animation.TranslateAnimation; public class Main{ /* w ww.j a va 2 s . c om*/ public static void invisibleViewByAlpha(final View view, long durationMillis, final boolean isBanClick, final AnimationListener animationListener) { if (view.getVisibility() != View.INVISIBLE) { view.setVisibility(View.INVISIBLE); AlphaAnimation hiddenAlphaAnimation = AnimationUtil .getHiddenAlphaAnimation(durationMillis); hiddenAlphaAnimation .setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { if (isBanClick) { view.setClickable(false); } if (animationListener != null) { animationListener .onAnimationStart(animation); } } @Override public void onAnimationRepeat(Animation animation) { if (animationListener != null) { animationListener .onAnimationRepeat(animation); } } @Override public void onAnimationEnd(Animation animation) { if (isBanClick) { view.setClickable(true); } if (animationListener != null) { animationListener.onAnimationEnd(animation); } } }); view.startAnimation(hiddenAlphaAnimation); } } public static void invisibleViewByAlpha(final View view, long durationMillis, final AnimationListener animationListener) { invisibleViewByAlpha(view, durationMillis, false, animationListener); } public static void invisibleViewByAlpha(final View view, long durationMillis, boolean isBanClick) { invisibleViewByAlpha(view, durationMillis, isBanClick, null); } public static void invisibleViewByAlpha(final View view, long durationMillis) { invisibleViewByAlpha(view, durationMillis, false, null); } public static void invisibleViewByAlpha(final View view, boolean isBanClick, final AnimationListener animationListener) { invisibleViewByAlpha(view, AnimationUtil.DEFAULT_ANIMATION_DURATION, isBanClick, animationListener); } public static void invisibleViewByAlpha(final View view, final AnimationListener animationListener) { invisibleViewByAlpha(view, AnimationUtil.DEFAULT_ANIMATION_DURATION, false, animationListener); } public static void invisibleViewByAlpha(final View view, boolean isBanClick) { invisibleViewByAlpha(view, AnimationUtil.DEFAULT_ANIMATION_DURATION, isBanClick, null); } public static void invisibleViewByAlpha(final View view) { invisibleViewByAlpha(view, AnimationUtil.DEFAULT_ANIMATION_DURATION, false, null); } }