How to Scroll to the Bottom of a Recyclerview? Scrolltoposition Doesn't Work

How to scroll to the bottom of a RecyclerView? scrollToPosition doesn't work

Just set setStackFromEnd=true or setReverseLayout=true so that LLM will layout items from end.

The difference between these two is that setStackFromEnd will set the view to show the last element, the layout direction will remain the same. (So, in an left-to-right horizontal Recycler View, the last element will be shown and scrolling to the left will show the earlier elements)

Whereas setReverseLayout will change the order of the elements added by the Adapter. The layout will start from the last element, which will be the left-most in an LTR Recycler View and then, scrolling to the right will show the earlier elements.

Sample:

final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
linearLayoutManager.setReverseLayout(true);
_listView.setLayoutManager(linearLayoutManager);

See documentation for details.

Scroll to the bottom of the Recycler View problem

I had a mistake that I put the recycler view inside a scroll view, so the code I used above didn't work like expected, just remove the scroll view and everything is normal again.

Automatically scroll to bottom of RecyclerView

Please use smoothScrollToPosition to fix your issue.
I always use smoothScrollToPosition for redirecting to any position.

Make sure, mMessages size is good as you thinking.

Example,

RecyclerView rv = (RecyclerView)findViewById(R.id.recyclerView);
rv.smoothScrollToPosition(mMessages.count-1);

RecyclerView - Scroll To Position Not Working Every Time

I had the same issue some weeks ago, and found only a really bad solution to solve it. Had to use a postDelayed with 200-300ms.

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
yourList.scrollToPosition(position);
}
}, 200);

If you found a better solution, please let me know! Good luck!

RecyclerView scrolling to the bottom

You can scroll to last position of recycler view by adding this line

recyclerView.scrollToPosition(YourArraylist.size()-1);

add this after setting adapter



Related Topics



Leave a reply



Submit