How to add a delay between animations in AnimatorSet playSequentially()?
Asked Answered
A

3

6

I'm using AnimatorSet playSequentially method like this:

AnimatorSet set = new AnimatorSet();
ObjectAnimator in = ObjectAnimator.ofFloat(splash, "alpha", 0f, 1f);
in.setDuration(2500);
in.setInterpolator(new AccelerateInterpolator());
ObjectAnimator out = ObjectAnimator.ofFloat(splash, "alpha", 1f, 0f);
out.setDuration(2500);
out.setInterpolator(new AccelerateInterpolator());

set.playSequentially(in,out);

I would like to add a delay between animation 1 and 2, like this:

set.playSequentially(in,1000,out);

It is possible to add delays between animations using playSequentially method?

Aeroneurosis answered 15/8, 2016 at 9:58 Comment(0)
W
7

Add this line of code:

    out.setStartDelay(1000);
Was answered 15/8, 2016 at 10:3 Comment(0)
W
1

You could set a start delay on the 2nd Animator (i.e. out.setStartDelay(1000)) before adding it to the set.

Weigand answered 29/11, 2016 at 2:20 Comment(0)
A
0

Rather than setting a start delay on the individual animations, use the AnimatorSet.after(long delay) function.

AnimatorSet s = new AnimatorSet();
s.play(anim1).after(1000).after(anim2);

AnimatorSet.Builder

Auld answered 10/11, 2020 at 2:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.