2

I want to put some delay for starting of an animation. So, when an animation is not going to repeat, we can easily use startOffset property. The thing is I have an animation which is going to repeat infinitely. But I have to start it with a delay, so when I use startOffset, the animation always repeat with that delay which is not what I want. Also I don't want to use Handler for creating delay.

EDIT:

I have never used ObjectAnimator. My code is like below but it doesn't animating. What is my mistake?

ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view, "translationX", 1000, -1000);
objectAnimator.setDuration(ANIMATION_DURATION);
objectAnimator.setRepeatMode(ValueAnimator.RESTART);
objectAnimator.setRepeatCount(ValueAnimator.INFINITE);
objectAnimator.setStartDelay((5 - i) * INTERVAL);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(objectAnimator);
animatorSet.start();
A. Badakhshan
  • 1,045
  • 7
  • 22

1 Answers1

2

If you are using VectorDrawable and AnimatedVectorDrawable in XML files in res/drawable folder and defined your animation in an objectAnimator file in res/animator folder then the startOffset delay works on the first occasion only not during repetitions. Repetitions are immediate. On the other hand if you want the animation to start with the delay everytime it repeats then I believe onAnimationEnd resetting works.