I have a RecyclerView, it has 30 items and when I scroll to the end to load another 30 items, it goes to the first item.
I tried to get current visible item then scroll to it when new items are added
((LinearLayoutManager) recyclerview1.getLayoutManager()).scrollToPositionWithOffset(layoutManager.findFirstVisibleItemPosition(), 0);
But it is not that smooth.
I tried to scroll to listmap.size()
but it will force the RecyclerView to scroll to the end of the list (if the user scrolled up).
I have seen some apps when I scroll to the bottom, new items are added smoothly that I can’t even notice that the change is made.
I need a solution, thanks in advance.
Advertisement
Answer
I’m posting the solution here thanks to Vastal. This code to avoid my main problem in the question:
recyclerview.getAdapter().notifyItemInserted(detailsList.size() -1);
And this one to load more items. Should be added in onScroll:
if (!recyclerview.canScrollVertically(1)) { _loadMore(); }