Example usage for android.view.animation AlphaAnimation setInterpolator

List of usage examples for android.view.animation AlphaAnimation setInterpolator

Introduction

In this page you can find the example usage for android.view.animation AlphaAnimation setInterpolator.

Prototype

public void setInterpolator(Interpolator i) 

Source Link

Document

Sets the acceleration curve for this animation.

Usage

From source file:Main.java

public static Animation inAlphaAnimation() {
    AlphaAnimation alpha = new AlphaAnimation(0.0f, 1.0f);
    alpha.setDuration(1000);//from  ww  w  .  ja  va  2  s.  com
    alpha.setInterpolator(new AccelerateInterpolator());
    return alpha;
}

From source file:Main.java

public static Animation outAlphaAnimation() {
    AlphaAnimation alpha = new AlphaAnimation(1.0f, 0.0f);
    alpha.setDuration(1000);/* w w  w  .  j  a  va2  s.  c  o  m*/
    alpha.setInterpolator(new AccelerateInterpolator());
    return alpha;
}

From source file:Main.java

public static Animation createAlphaAnimation(float fromAlpha, float toAlpha, long duration) {
    AlphaAnimation anim = new AlphaAnimation(fromAlpha, toAlpha);
    anim.setDuration(duration);//w ww  .  ja  v a 2  s. c  o  m
    anim.setInterpolator(new AccelerateInterpolator());
    return anim;
}

From source file:Main.java

public static void fadeIn(View view, int durationMillis) {
    if (view != null) {
        AlphaAnimation fadeImage = new AlphaAnimation(0, 1);
        fadeImage.setDuration(durationMillis);
        fadeImage.setInterpolator(new DecelerateInterpolator());
        view.startAnimation(fadeImage);//ww w.ja  v  a2s  .c  o m
    }
}

From source file:Main.java

public static Animation fadeInLong(final android.view.animation.Animation.AnimationListener animationlistener) {
    final AlphaAnimation alphaanimation = new AlphaAnimation(0F, 1F);
    alphaanimation.setDuration(600L);//  w  w  w . ja v a 2 s .  com
    alphaanimation.setInterpolator(new LinearInterpolator());
    alphaanimation.setAnimationListener(animationlistener);
    return alphaanimation;
}

From source file:Main.java

public static Animation fadeOut(final android.view.animation.Animation.AnimationListener animationlistener) {
    final AlphaAnimation alphaanimation = new AlphaAnimation(1F, 0F);
    alphaanimation.setDuration(300L);/* w  ww.  j a v a  2  s. c  o  m*/
    alphaanimation.setInterpolator(new LinearInterpolator());
    alphaanimation.setAnimationListener(animationlistener);
    return alphaanimation;
}

From source file:Main.java

public static Animation fadeIn(final android.view.animation.Animation.AnimationListener animationlistener) {
    final AlphaAnimation alphaanimation = new AlphaAnimation(0F, 1F);
    alphaanimation.setDuration(300L);//from   www. j  a  v  a 2s.  c o m
    alphaanimation.setInterpolator(new LinearInterpolator());
    alphaanimation.setAnimationListener(animationlistener);
    return alphaanimation;
}

From source file:Main.java

public static void setAlphaAnim(float fromAlpha, float toAlpha, long duration) {
    AlphaAnimation alphaAnimation = new AlphaAnimation(fromAlpha, toAlpha);
    alphaAnimation.setDuration(duration);
    alphaAnimation.setInterpolator(new LinearInterpolator());

}

From source file:Main.java

/**
 * Animate a view to fade in./*  www. j ava  2 s. c o m*/
 *
 * @param view         The view to be animated.
 * @param duration     Duration that the animation should run, in milliseconds; specify -1 to use the default.
 * @param interpolator The interpolator which defines the acceleration curve; can be null to use default.
 */
public static void startFadeIn(View view, long duration, Interpolator interpolator) {
    AlphaAnimation alphaAnimation = new AlphaAnimation(0f, 1f);
    if (duration > 0) {
        alphaAnimation.setDuration(duration);
    }
    if (interpolator != null) {
        alphaAnimation.setInterpolator(interpolator);
    }
    view.startAnimation(alphaAnimation);
}

From source file:Main.java

public static void SetMenuAnimation(final ImageView v, final int bg1, final int bg2) {
    v.setImageResource(bg1);/*from ww  w  . jav  a  2 s.c om*/
    AlphaAnimation anim = new AlphaAnimation(0.8f, 1);
    anim.setDuration(1000);
    anim.setRepeatCount(Animation.INFINITE);
    // anim1.setRepeatMode(Animation.REVERSE);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.setAnimationListener(new AnimationListener() {
        @Override
        public void onAnimationStart(Animation arg0) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onAnimationRepeat(Animation arg0) {
            // TODO Auto-generated method stub
            num++;
            if (num == 10) {
                num = 0;
            }
            if (num % 2 == 0) {
                v.setImageResource(bg1);
            } else {
                v.setImageResource(bg2);
            }
        }

        @Override
        public void onAnimationEnd(Animation arg0) {
            // TODO Auto-generated method stub

        }
    });
    v.startAnimation(anim);

}