I'm using android KitKat and this seems to be not working as expected. I have an AnimatiorSet which should start after some delay but I want to make some action when the animation actually starts (after the delay). It seems that AnimatorSet invokes onAnimationStarted on listeners immediately after calling start().
Sample code below:
AnimatorSet set = new AnimatorSet();
set.playTogether(
ObjectAnimator.ofFloat(obj, "x", 10),
ObjectAnimator.ofFloat(obj, "y", 10));
set.setStartDelay(5000);
set.setDuration(1000)
set.addListener(new AnimatorListenerAdapter()
{
@Override
public void onAnimationStart(Animator animation)
{
// do sth
}
});
set.start();
In this case the listener is invoked immediately instead of delayed. To work around this issue I checked if adding the listener to the animators passed into playTogether gives the expected result and it actually does. Is this a bug?
Another workaround for that is:
@Override
public void onAnimationStart(Animator animator) {
rootView.postDelayed(new Runnable() {
@Override
public void run() {
// todo
}
}, set.getStartDelay());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With