When I add new data to my RecycleView, if I'm at the top of the view then I get scrolled down a tiny bit. How do I correctly scroll to the top of a RecycleView? I have tried:
boolean isAtTop = !mRecyclerView.canScrollVertically(-1);
mRecyclerAdapter.updateMessageItemDataList(mMessageItems);
if (isAtTop)
mRecyclerView.scrollToPosition(0);
But that does nothing (I still get scrolled down a tiny bit). I searched on Stack overflow and found the following, which still doesn't do anythnig:
boolean isAtTop = !mRecyclerView.canScrollVertically(-1);
mRecyclerAdapter.updateMessageItemDataList(mMessageItems);
if (isAtTop)
((LinearLayoutManager)mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0);
isAtTop is always being identified correctly, but my attempts to scroll back up to the top never work. Has anyone ever encountered a similar issue.
It's really weird because I can scroll to the bottom of the view correctly using
mRecyclerView.scrollToPosition(mRecyclerAdapter.getItemCount() - 1);