问题
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?
回答1:
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).
来源:https://stackoverflow.com/questions/31787531/recyclerview-notifyiteminserted-animation-not-showing-when-position-is-0-but-w