What is the difference between clearAnimation () and stop () in android?

When I finish my work, should I use clearAnimation() or stop() for all remaining AnimationDrawable objects?

+6
source share
1 answer

stop() stops the animation and that’s it. Since stop () is an AnimationDrawable.class method, you can use it when you want to stop AnimationDrawable animation, but not in any view.

clearAnimation() is a method of the View.class class. This will stop the viewing animation and additionally:

  • If there is an AnimationListener defined, AnimationListener.onAnimationEnd(Animation animation) will be called.

  • If defined Handler Handler.postAtFrontOfQueue(Runnable r) .

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); } } 
0
source

Source: https://habr.com/ru/post/909062/


All Articles