在AnimatorSet.playSequentially()中如何添加动画之间的延迟?

6
我正在使用AnimatorSet的playSequentially方法,代码如下:
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);

我想在动画1和2之间添加延迟,如下所示:

set.playSequentially(in,1000,out);

使用playSequentially方法可以在动画之间添加延迟。谢谢。
3个回答

7
请添加这行代码:
    out.setStartDelay(1000);

1

在将第二个Animator添加到集合中之前,您可以为其设置启动延迟(例如:out.setStartDelay(1000))。


0
不要在单个动画上设置启动延迟,而是使用AnimatorSet.after(long delay)函数。
AnimatorSet s = new AnimatorSet();
s.play(anim1).after(1000).after(anim2);

AnimatorSet.Builder


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接