I am using a RecyclerView, I add items before the first item, the scroll position moves up to the newly first item added. How can I maintain my scroll position after adding
There are two options:
Use the more sophisticated versions of notify
List newData = createLineItems(dataArrayList);
mCurrentFragment.items.addAll(0, newData);
notifyItemRangeInserted(0, newData.size());
Use stable IDs. On your adapter override public long getItemId (int position)
to make it return MEANINGFUL values and call setHasStableIds(true);
on it.