I have a list of items. These items are sorted by date. Items with date before now ("old" items) should not be visible when user opens application but user should be able to see them by scrolling list to top.
I find position
of first item with date in the future ("new" item) and call recyclerView.scrollToPosition(position)
.
I also tried layoutManager.scrollToPositionWithOffset(position, 0)
.
This works if there are many "new" items in the list.
But if there are too few items (for example, one "old" and one "new") then these methods do not work.
How can I scroll list programmatically to item at given position to place this item on top regardless of how many there are items in the list?