When I finishing my activity, should I use clearAnimation()
or stop()
on any remaining AnimationDrawable
objects?
stop()
stops the animation and that's all. Since stop() is method of AnimationDrawable.class
you can use it when you want to stop the animation of AnimationDrawable
, but not on any View.
clearAnimation()
is method of the View.class
. It will stop the animation of the View and additionally:
If there is AnimationListener
defined, AnimationListener.onAnimationEnd(Animation animation)
will be called.
If there is Handler
defined Handler.postAtFrontOfQueue(Runnable r)
will be called.
Here is the call hierarchy:
View.clearAnimation()
-> Animation.detach()
-> Animation.fireAnimationEnd()
and the fireAnimationEnd()
method:
private void fireAnimationEnd() {
if (mListener != null) {
if (mListenerHandler == null) mListener.onAnimationEnd(this);
else mListenerHandler.postAtFrontOfQueue(mOnEnd);
}
}
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