1

I currently have a recycler view which contains image view in grid layout. I have delete icon using which I can set the state of recycler view to delete mode. If delete icon is clicked recycler view items goes to delete mode which means checkbox appears on image view which if selected can be deleted or if back button is clicked recycler view restores to normal state where check box disappears.

My problem is when I am going to delete mode and then coming back to normal state using back key my recycler view blinks. It happens only when I repeat the process again and again i.e delete mode -> back button -> delete mode -> back button -> repeat -> it blinks.

I have implemented These two solutions>>

  1. setHasStableIds(true)

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

pooh2
  • 11
  • 2

1 Answers1

0

The problem appears to be that the image views are re-drawn, which causes the blink. You can verify this by not showing the image views and if no blinks happens, that's the cause.

Solution

The solution is to avoid re-drawing the image views when you go into delete mode.

  • If you are extending ListAdapter for your recycler view, see this article.
  • If not (and you manually call notifyDatasetChanged()), see this answer.
Minas Mina
  • 2,058
  • 3
  • 21
  • 35