I have a TranslateAnimation
on my class. The animation starts automatically.
I set button that if it is clicked, the animation will be canceled (animation.cancel();
).
I also set an AnimationListener for my class. If my animation ends, I will start a new Activity (you go to the menu).
public void onAnimationEnd(Animation animation) {
startActivity(new Intent(Class.this, Class2.class));
}
My app is relying on that the user has to click the button before the animation ends.
The problem is that animation.cancel();
is admitted as the end of the animation.
How to cancel the animation in the other way that was not counted as the end of the animation? Is that possible?
Thanks in advance!
cancel() The Web Animations API's cancel() method of the Animation interface clears all KeyframeEffect s caused by this animation and aborts its playback. Note: When an animation is cancelled, its startTime and currentTime are set to null .
Open Settings . Scroll down and select Accessibility. Scroll down to Display and tap Text and display. Tap the toggle switch for Remove animations to turn it on.
Once the animation is cancelled, you can remove the listener thus preventing onAnimationEnd
from being called:
@Override
public void onAnimationCancel(Animator animation) {
animation.removeAllListeners();
}
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