0

I have three animations (translate) that I want to execute linearly. Animation 1 starts, Animation 2 starts when Animation 1 ends, and Animation 3 starts when Animation 2 ends.

So far the only thing I am able to do is up to two animation with a AnimationEnd method which executes Animation 2.

How would I be able to up to X animation linearly?

Also the animation set seems to execute animations at the same time so that is no help for me.

2 Answers2

1

Use animation's android:startOffset attribute.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • I tried putting 3 animations in an animation set with offset time after each other but doesn't work. Can you provide an example please. – confusedCoder Jun 27 '11 at 15:26
0

You'll want to use an AnimationSet and set the appropriate startOffsets:

AnimationSet animations = new AnimationSet(false);

Animation scaleAnimation = new ScaleAnimation(...);
scaleAnimation.setDuration(500);
animations.addAnimation(scaleAnimation);

Animation translateAnimation = new TranslateAnimation(...);
translateAnimation.setStartOffset(500);
translateAnimation.setDuration(500);
animations.addAnimation(translateAnimation);

myView.startAnimation(animations);
AlexD
  • 813
  • 9
  • 15