Example usage for android.view.animation Animation REVERSE

List of usage examples for android.view.animation Animation REVERSE

Introduction

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

Prototype

int REVERSE

To view the source code for android.view.animation Animation REVERSE.

Click Source Link

Document

When the animation reaches the end and the repeat count is INFINTE_REPEAT or a positive value, the animation plays backward (and then forward again).

Usage

From source file:Main.java

public static AlphaAnimation fadeBackgroundAnimation() {
    AlphaAnimation alpha = new AlphaAnimation(0.5f, 0.2f);
    alpha.setRepeatCount(Animation.INFINITE);
    alpha.setRepeatMode(Animation.REVERSE);
    alpha.setDuration(1200);/*from  w  w  w.j  av  a  2 s  .c o  m*/
    alpha.setFillAfter(true);
    return alpha;
}

From source file:Main.java

public static void alphaAnimation(View v, float fromAlpha, float toAlpha, long durationMillis,
        boolean fillAfter) {
    AlphaAnimation animation = new AlphaAnimation(fromAlpha, toAlpha);
    animation.setDuration(durationMillis);
    animation.setFillAfter(fillAfter);//from  w  w  w .ja v  a2  s.  c o m
    animation.setRepeatMode(Animation.REVERSE);
    v.startAnimation(animation);
}

From source file:Main.java

public static void startTranslationAnimation(View view) {
    TranslateAnimation translateAnimation = new TranslateAnimation(-50f, 50f, 0, 0);
    translateAnimation.setDuration(1000);
    translateAnimation.setRepeatCount(Animation.INFINITE);
    translateAnimation.setRepeatMode(Animation.REVERSE);
    view.setAnimation(translateAnimation);
    translateAnimation.start();/* w w  w.ja  v a 2 s . c om*/
}

From source file:Main.java

public static void animateView(View view) {
    final Animation animation = new AlphaAnimation(1f, 0f);
    animation.setDuration(1000); // Animate for 1 seconds
    animation.setInterpolator(new LinearInterpolator());
    animation.setRepeatCount(Animation.INFINITE);
    animation.setRepeatMode(Animation.REVERSE);
    view.startAnimation(animation);//from   w ww. j ava 2  s  . c o  m
}

From source file:Main.java

public static void animaBotao(Button botao) {
    final Animation animation = new AlphaAnimation(1, 0); // Change alpha from fully visible to invisible
    animation.setDuration(400);//from  w w  w  . j a  v a2  s  .  c om
    animation.setInterpolator(new LinearInterpolator()); // do not alter animation rate
    animation.setRepeatCount(2);
    animation.setRepeatMode(Animation.REVERSE); // Reverse animation at the end so the button will fade back in
    botao.startAnimation(animation);
}

From source file:Main.java

public static void startBlink(View view) {
    if (null == view) {
        return;/* www .java 2 s  . c o m*/
    }
    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

public static AnimationSet FlipAnimation(int duration, int repeatCount) {
    AnimationSet flip = new AnimationSet(true);
    if (duration > 20) //Flip anim
    {//from  w  w w  .  ja  va 2  s.c  om
        Animation from_middle1_anim = new ScaleAnimation(1.0f, 0.0f, 1.0f, 1.0f, Animation.RELATIVE_TO_SELF,
                .5f, Animation.RELATIVE_TO_SELF, .5f);
        from_middle1_anim.setDuration(duration);
        from_middle1_anim.setStartOffset(0);
        from_middle1_anim.setRepeatMode(Animation.REVERSE);
        from_middle1_anim.setRepeatCount(repeatCount);

        flip.addAnimation(from_middle1_anim);
    } else // no anim
    {
        Animation noAnim = new AlphaAnimation(1f, 1f);
        noAnim.setDuration(duration);
        flip.addAnimation(noAnim);
    }
    return flip;
}

From source file:Main.java

public static void setFlickerAnimation(View v) {
    final Animation animation = new AlphaAnimation(1, 0); // Change alpha
    animation.setDuration(500); // duration - half a second
    animation.setInterpolator(new LinearInterpolator()); // do not alter
                                                         // animation
                                                         // rate
    animation.setRepeatCount(Animation.INFINITE); // Repeat animation
                                                  // infinitely
    animation.setRepeatMode(Animation.REVERSE); //
    v.setAnimation(animation);/*from  ww  w.j a v  a2s . c  o  m*/
}

From source file:Main.java

public static void blink(View view, int durationMs, int repeatCount) {
    Animation anim = new AlphaAnimation(1.0f, 0.0f);
    anim.setDuration(durationMs); //You can manage the time of the blink with this parameter
    anim.setStartOffset(0);//  ww w  .  j  a  va 2s. com
    anim.setRepeatMode(Animation.REVERSE);
    anim.setRepeatCount(repeatCount);
    view.startAnimation(anim);

}

From source file:com.example.android.google.wearable.watchviewstub.MainActivity.java

/**
 * Animates the layout when clicked. The animation used depends on whether the
 * device is round or rectangular./*from  w ww  .ja va 2  s  .c  om*/
 */
public void onLayoutClicked(View view) {
    if (mRectBackground != null) {
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.7f, 1.0f, 0.7f, Animation.RELATIVE_TO_SELF,
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        scaleAnimation.setDuration(300);
        scaleAnimation.setRepeatCount(1);
        scaleAnimation.setRepeatMode(Animation.REVERSE);
        mRectBackground.startAnimation(scaleAnimation);
    }
    if (mRoundBackground != null) {
        mRoundBackground.animate().rotationBy(360).setDuration(300).start();
    }
}