I have this animation issue in RecylcerView, in a ...
# random
I have this animation issue in RecylcerView, in a chat app, inserting a new message, then after it is sent, updating it (message.state changes). Insert animation plays okay however during when the update (notifyItemChanged(payload) comes, it just jumps to end position, stopping the animation
Disable the default item animator's change animation
Same thing unfortunately
fyi its because of this in DefaultItemAnimator
Copy code
    public boolean animateChange(RecyclerView.ViewHolder oldHolder, RecyclerView.ViewHolder newHolder,
            int fromX, int fromY, int toX, int toY) {
        if (oldHolder == newHolder) {
            // Don't know how to run change animations when the same view holder is re-used.
            // run a move animation to handle position changes.
            return animateMove(oldHolder, fromX, fromY, toX, toY);
        final float prevTranslationX = oldHolder.itemView.getTranslationX();
        final float prevTranslationY = oldHolder.itemView.getTranslationY();
        final float prevAlpha = oldHolder.itemView.getAlpha();
        resetAnimation(oldHolder); <------------- THIS
Whats the call stack?
The javadoc of
Copy code
* @param supportsChangeAnimations true if change animations are supported by
     *                                 this ItemAnimator, false otherwise. If the property is false,
     *                                 the ItemAnimator
     *                                 will not receive a call to
     *                                 {@link #animateChange(RecyclerView.ViewHolder, RecyclerView.ViewHolder, int, int, int,
     *                                 int)} when changes occur.
So my suggestion should have fixed that
Yea javadoc sounds it should but it doesnt for some reason, unless im using it wrong
(recyclerView.itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
File a bug?
Copy code
fun RecyclerView.disableChangeAnimation() {
  val animator = itemAnimator
  if (animator is SimpleItemAnimator) {
    animator.supportsChangeAnimations = false
btw now I tried to subclass the defaultitemanimator, and just dont call super on that animateChangeMethod and it works
Set a breakpoint and check where the call is coming from
when the flag is false?
Set a breakpoint to the first line of
and check who called it in the callstack
only thing different is that with the flag false, it behaves as notifyItemChanged ( payload ) overload, i.e. oldHolder and newHolder are the same so it goes to animateMove, with not deltaX Y so it just calls endAnimation which cancels the translation animator from notifyItemInserted