title: Android: How to restart Animation after clear it
body: <p>Can't find a solution to start the animation again after i call myImageView.clearAnimation(). The animation gets set in onPageSelected but the startoffset timeout dont work.</p>
  
  <p>Or is there any other method to cancel thr animation to get a untouched imageview and when
  onPageSelected is called start the same animation for the same view agian.</p>
  
  <p>I tryed to call myImageView.getAnimation().retart() in onPageScrollStateChanged but the animation is still on the view...</p>
  
  <p>Here's my code:</p>
  
  <pre><code>public class myActivity extends Activity {
  ...
  private ImageView myImageView;
  
  private static final Integer startOffset = 5000;
  private static final Integer duration= 2500;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      ...
      currentImageView = (ImageView) findViewById(R.id.dashboardIndicator);
      currentImageView.setAnimation(indicatorAnimation());
      ...
  }
  
  private Animation indicatorAnimation() {
      Animation alphaAnimation = new AlphaAnimation(1, 0.2F);
      alphaAnimation.setInterpolator(new AccelerateInterpolator());
      alphaAnimation.setStartOffset(startOffset);
      alphaAnimation.setDuration(duration);
      alphaAnimation.setFillAfter(true);
  
      return alphaAnimation;
  }
  
  ViewPager.OnPageChangeListener onPageChangeListener = new ViewPager.OnPageChangeListener() {
      @Override
      public void onPageSelected(int position) {
          // Need here to start the animation again
          myImageView.setAnimation(indicatorAnimation());
          // Set's the animation but don't starts it after the startOffset timeout
      }
  
      @Override
      public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { }
  
      @Override
      public void onPageScrollStateChanged(int position) {
          // Need here to cancel the animation to have no Alpha value on the imageview
          myImageView.clearAnimation();
          // image view 100% visible
      }
  };}
  </code></pre>