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.
SimpleItemAnimator itemAnimator = myRecyclerView.getItemAnimator()itemAnimator.setSupportsChangeAnimations(false);
OR, in single line
((SimpleItemAnimator) myRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
Quick Links
Legal Stuff
Social Media