Android recyclerview remove all item decorators
I did this:
dividerItemDecoration = new DividerItemDecoration( recyclerView.getContext(), DividerItemDecoration.VERTICAL ); recyclerView.addItemDecoration(dividerItemDecoration);
Then I change the orientation of the devices, so now I don't have this dividerItemDecoration and I want to remove the divider from the recyclerView. Is it possible?
+3
Ivan Salosin
source
to share
2 answers
To remove ItemDecoration you need to use removeItemDecoration . For your case, the code would be:
recyclerView.removeItemDecoration(dividerItemDecoration);
+7
Dheeraj Nair
source
to share
You can do it like this:
while (recyclerView.getItemDecorationCount() > 0) {
recyclerView.removeItemDecorationAt(0);
}
+1
Szymon chaber
source
to share