Override animation for notifyItemChanged in RecyclerView.Adapter

Solution 1:

There is a dedicated method to disable just item changed animations:

((SimpleItemAnimator) myRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);

Official docs.

Solution 2:

Yes, I did.

First, get the source code of DefaultItemAnimator. Take the code and create a class named MyItemAnimator in your project. Then, set the ItemAnimator to a new instance of your modified MyItemAnimator, like so:

recyclerView.setItemAnimator(new MyItemAnimator());

Now, go in the new classes source code and locate the method

animateChangeImpl(final ChangeInfo changeInfo) { ... }

We simply have to locate the method calls changing alpha values. Find the following two lines and remove the .alpha(0) and .alpha(1)

oldViewAnim.alpha(0).setListener(new VpaListenerAdapter() { ... }
newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration()).alpha(1).setListener(new VpaListenerAdapter() { ... }

like so

oldViewAnim.setListener(new VpaListenerAdapter() { ... }
newViewAnimation.translationX(0).translationY(0).setDuration(getChangeDuration()).setListener(new VpaListenerAdapter() { ... }

Solution 3:

Try setting:

mRecyclerview.setItemAnimator(null);