Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 379
touchchandra Avatar asked Aug 03 '15 12:08

touchchandra


1 Answers

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).

like image 142
yigit Avatar answered Nov 11 '22 22:11

yigit