When I run this code inside my user view, onAnimationStart and onAnimationEnd constantly repeating. Isn't that weird? As an Android programmer, I expected them to be called only once, respectively.
final ViewPropertyAnimator animator = animate().setDuration(1000).alpha(0.0f); animator.setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { Utils.log("----------------start"); } @Override public void onAnimationEnd(Animator animation) { Utils.log("--------- end"); } }).start();
But then I tried to fix the problem by removing the listener when onAnimationEnd gets a call to ViewPropertyAnimator setListener(null) , but it never worked, despite the fact that it is written in the documents:
public ViewPropertyAnimator setListener (Animator.AnimatorListener listener) Added in API level 12 Sets a listener for events in the underlying Animators that run the property animations. Parameters listener The listener to be called with AnimatorListener events. A value of null removes any existing listener. Returns This object, allowing calls to methods in this class to be chained.
Does anyone else run into this weird problem? maybe this is an android bug?
source share