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

问题描述 投票:0回答:3

我正在使用 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 方法在动画之间添加延迟吗?

android animation android-animation objectanimator animatorset
3个回答
7
投票

添加这行代码:

    out.setStartDelay(1000);

1
投票

您可以在将第二个动画器添加到集合之前设置启动延迟(即

out.setStartDelay(1000)
)。


0
投票

而不是为各个动画设置启动延迟, 使用

AnimatorSet.after(long delay)
功能。

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

AnimatorSet.Builder

© www.soinside.com 2019 - 2024. All rights reserved.