Create repeat animation out of TranslateAnimation for ImageView - Android android.widget

Android examples for android.widget:ImageView

Description

Create repeat animation out of TranslateAnimation for ImageView

Demo Code

import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class Main {

  public static void repeat(ImageView imageView) {
    TranslateAnimation alphaAnimation2 = new TranslateAnimation(150f, 350f, 50, 50);
    alphaAnimation2.setDuration(1000);/*from w  w w .  j  a va2 s  .  c o  m*/
    alphaAnimation2.setRepeatCount(Animation.INFINITE);
    alphaAnimation2.setRepeatMode(Animation.REVERSE);
    imageView.setAnimation(alphaAnimation2);
    alphaAnimation2.start();
  }

}

Related Tutorials