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();