How to fix blinking issue for RecyclerView notify changes

Fetching Comments ...

How to fix blinking issue for RecyclerView notify changes

If you are Android developer then you surely use RecyclerView to show list of items to users. And you also developed such apps which requires data changes frequently in RecyclerView. And you may noticed that whenever you use adapter. NotifyDataSetChanged(), adapter.notifyItemChanged(int position) etc methods then your RecyclerView blink for few nanoseconds. And it looks like that your app is blinking due to lag. Actually this is due to Animation in RecyclerView. As stated in official documentation of RecyclerView that RecyclerView uses DefaltItemAnimator by default. Which means if you doesn’t specify ItemAnimator to RecyclerView then it still got animations.

You can see those animation while removing items or adding new items to RecyclerView. So simple trick is disable animations in RecyclerView item and your problem will be resolved.

Below is code to disable animations in RecyclerView.

SimpleItemAnimator  itemAnimator = myRecyclerView.getItemAnimator()

OR, in single line

((SimpleItemAnimator) myRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
Share This:

LearnPainLess On Instagram

Get The Best Of All Hands Delivered To Your Inbox

Subscribe to our newsletter and stay updated.