touchchandra
touchchandra

Reputation: 1556

RecyclerView notifyItemInserted() Animation not showing when position is 0 but works fine with other position

I am using

data.add(0,item);
notifyItemInserted(0);

This works fine as long as the items space is not filled up. After that, animation is not seen.

animation works fine when i do

data.add(1,item);
notifyItemInserted(1);

How to add items in 0 position and show animation all the time. Do I have to use scrollToPosition?

Upvotes: 5

Views: 3715

Answers (1)

yigit
yigit

Reputation: 38263

call scrollToPosition(0) if you wan't it to scroll to position 0 after new item is added. RecyclerView will just keep the current top item in place, which is why you are not seeing the new item. (the new item is being added above the visible area).

Upvotes: 6

Related Questions