visible View By Alpha Animation - Android Animation

Android examples for Animation:Animation to Show

Description

visible View By Alpha Animation

Demo Code


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{
    /*www  .j av a  2s .  com*/
    public static void visibleViewByAlpha(final View view,
            long durationMillis, final boolean isBanClick,
            final AnimationListener animationListener) {
        if (view.getVisibility() != View.VISIBLE) {
            view.setVisibility(View.VISIBLE);
            AlphaAnimation showAlphaAnimation = AnimationUtil
                    .getShowAlphaAnimation(durationMillis);
            showAlphaAnimation
                    .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(showAlphaAnimation);
        }
    }
    
    public static void visibleViewByAlpha(final View view,
            long durationMillis, final AnimationListener animationListener) {
        visibleViewByAlpha(view, durationMillis, false, animationListener);
    }
    
    public static void visibleViewByAlpha(final View view,
            long durationMillis, final boolean isBanClick) {
        visibleViewByAlpha(view, durationMillis, isBanClick, null);
    }
    
    public static void visibleViewByAlpha(final View view,
            long durationMillis) {
        visibleViewByAlpha(view, durationMillis, false, null);
    }
    
    public static void visibleViewByAlpha(final View view,
            final boolean isBanClick,
            final AnimationListener animationListener) {
        visibleViewByAlpha(view, AnimationUtil.DEFAULT_ANIMATION_DURATION,
                isBanClick, animationListener);
    }
    
    public static void visibleViewByAlpha(final View view,
            final AnimationListener animationListener) {
        visibleViewByAlpha(view, AnimationUtil.DEFAULT_ANIMATION_DURATION,
                false, animationListener);
    }
    
    public static void visibleViewByAlpha(final View view,
            final boolean isBanClick) {
        visibleViewByAlpha(view, AnimationUtil.DEFAULT_ANIMATION_DURATION,
                isBanClick, null);
    }
    
    public static void visibleViewByAlpha(final View view) {
        visibleViewByAlpha(view, AnimationUtil.DEFAULT_ANIMATION_DURATION,
                false, null);
    }
}

Related Tutorials