Example usage for android.view.animation AlphaAnimation AlphaAnimation

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

Introduction

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

Prototype

public AlphaAnimation(float fromAlpha, float toAlpha) 

Source Link

Document

Constructor to use when building an AlphaAnimation from code

Usage

From source file:Main.java

public static AlphaAnimation getInAlphaAnimation(long durationMillis) {
    AlphaAnimation inAlphaAnimation = new AlphaAnimation(0, 1);
    inAlphaAnimation.setDuration(durationMillis);
    return inAlphaAnimation;
}

From source file:Main.java

public static void animationAlpha(View paramView) {
    animation(paramView, new AlphaAnimation(0.2F, 1.0F), 1000L, 0L);
}

From source file:Main.java

public static void startBlink(View view) {
    if (null == view) {
        return;//from   w  ww  . jav a  2 s  .c om
    }
    Animation alphaAnimation = new AlphaAnimation(1, 0);
    alphaAnimation.setDuration(500);
    alphaAnimation.setInterpolator(new LinearInterpolator());
    alphaAnimation.setRepeatCount(Animation.INFINITE);
    alphaAnimation.setRepeatMode(Animation.REVERSE);
    view.startAnimation(alphaAnimation);
}

From source file:Main.java

@SuppressLint("NewApi")
public static Animation makeVisibleAnimated(final View view) {
    final Animation a = new AlphaAnimation(0.00f, 1.00f);
    a.setDuration(500);//from   w  w w  .  j a va  2s .c o m
    a.setAnimationListener(getFadeInListener(view));

    view.startAnimation(a);

    return a;
}

From source file:Main.java

public static AlphaAnimation getOutAlphaAnimation(long durationMillis) {
    AlphaAnimation outAlphaAnimation = new AlphaAnimation(1, 0);
    outAlphaAnimation.setDuration(durationMillis);
    return outAlphaAnimation;
}

From source file:Main.java

@SuppressLint("NewApi")
public static void setAlpha(View view, float alpha) {
    if (Build.VERSION.SDK_INT < 11) {
        final AlphaAnimation animation = new AlphaAnimation(alpha, alpha);
        animation.setDuration(0);/*  w  w w . ja  v  a  2 s . c o m*/
        animation.setFillAfter(true);
        view.startAnimation(animation);
    } else {
        view.setAlpha(alpha);
    }
}

From source file:Main.java

public static AnimationSet flash(final android.view.animation.Animation.AnimationListener animationlistener) {
    final AnimationSet animationset = new AnimationSet(true);
    final AlphaAnimation alphaanimation = new AlphaAnimation(0F, 1F);
    alphaanimation.setStartOffset(500L);
    alphaanimation.setDuration(100L);// w w  w .  jav a 2 s .  c  o m
    animationset.addAnimation(alphaanimation);
    final AlphaAnimation alphaanimation1 = new AlphaAnimation(1F, 0F);
    alphaanimation1.setDuration(100L);
    alphaanimation1.setStartOffset(1200L);
    animationset.addAnimation(alphaanimation1);
    animationset.setAnimationListener(animationlistener);
    return animationset;
}

From source file:Main.java

public static AlphaAnimation getaAlphaAnimation(int from, int to, int duration) {
    AlphaAnimation alphaAnimationShow = new AlphaAnimation(from, to);
    alphaAnimationShow.setDuration(duration);
    return alphaAnimationShow;
}

From source file:Main.java

public static void fadeAnimation(final View view, final float fromAlpha, final float toAlpha, long duration,
        final Runnable callback) {
    Animation anim = new AlphaAnimation(fromAlpha, toAlpha);
    anim.setDuration(duration);/*from   ww w . jav a 2s.co  m*/
    anim.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            view.setAlpha(toAlpha);
            if (toAlpha > 0)
                view.setVisibility(View.VISIBLE);
            else
                view.setVisibility(View.GONE);

            if (callback != null)
                callback.run();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });

    view.setVisibility(View.VISIBLE);
    view.startAnimation(anim);
}

From source file:Main.java

/**
 * @return A fade out animation from 100% - 0% taking half a second
 *///from ww w.j  a v  a 2s.  c o  m
public static Animation createFadeoutAnimation() {
    Animation fadeout = new AlphaAnimation(VISIBLE, INVISIBLE);
    fadeout.setDuration(HALF_A_SECOND);
    return fadeout;
}