Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I'm using a RecyclerView. After adding items to the RecyclerView, I need to call:
notifyItemRangeInserted(int positionStart, int itemCount);
However, this shows a sort of "slide down" animation. Is there a way that I can disable this animation?
Thanks.
recyclerView.setItemAnimator(null);
notifyItemRangeInserted(int positionStart, int itemCount);
recyclerView.setItemAnimator(new DefaultItemAnimator());
You can also do it with Data Binding in your xml layout file like this:
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemAnimator="@{null}" />
This is possible simply because RecyclerView has a public function called setItemAnimator
!
I'm using ListAdapter and Matthew's solution did not work for me, when I re-enable animation it active animation back. I use this if anybody else needed (Kotlin):
recyclerView.itemAnimator = null
adapter.submitList(items.toList()){
recyclerView.itemAnimator = DefaultItemAnimator()
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.