Add Items to top of recyclerview
I would insist you to add item at 0th
position which is coming from pull to refresh as below,
mArrayList.add(position, item);notifyItemInserted(position);
Add following line when you set your recyclerview
recyclerView.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.VERTICAL,true));
I also need to add items to the front of recyclerview(and to bottom), but i need to keep scroll focused at the previous top item.
So i'm scrolling recyclerview to previous top item:
mAdapter.pushFront(items);mAdapter.notifyItemRangeInserted(0, items.size());recyclerView.scrollToPosition(items.size() - 1);
Is there a better solution?