I want to scroll to the bottom of a recycler view on click of a button, how do I do this?
Asked
Active
Viewed 3.5k times
2 Answers
33
You have to make use of LayoutManager
for that. Follow the below steps.
1). First of all, declare LayoutManager
in your Activity/Fragment
. For example, I have taken LinearLayoutManager
private LinearLayoutManager mLinearLayoutManager;
2). Initialise the LinearLayoutManager
and set that to your RecyclerView
mLinearLayoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(mLinearLayoutManager);
3). On your Button onClick
, do this to scroll to the bottom of your RecyclerView
.
mLinearLayoutManager.scrollToPosition(yourList.size() - 1); // yourList is the ArrayList that you are passing to your RecyclerView Adapter.
Hope this will help..!!

Mukesh Rana
- 4,051
- 3
- 27
- 39
-
33) It should be mLinearLayoutManager.scrollToPosition(yourList.size() - 1); – Eliseo Ocampos Apr 21 '17 at 17:15
-
2If recycle view element is big (image for example) this show only start if item. So this not real scroll to bottom (I can still scroll more by hand after this) – Alex Oct 20 '18 at 16:03
-
@Alex Not working! Image in the list item is the cause? – Arnold Brown May 09 '20 at 05:38
-
1@ArnoldBrown No. Problem is that scrollToPosition() scroll to top of last element. And need scroll to bottom of last element. – Alex May 12 '20 at 13:36
3
You can use scrollToPosition() with the index of the last position.

Doug Stevenson
- 297,357
- 32
- 422
- 441
-
1Based on the doc, " RecyclerView does not implement scrolling logic, rather forwards the call to scrollToPosition(int)". It does not implement the logic, simply call this function will does nothing. – hjchin Nov 30 '16 at 14:05
-
2
-
Same as previous answer - If recycle view element is big (image for example) this show only start if item. So this not real scroll to bottom (I can still scroll more by hand after this) – Alex Oct 20 '18 at 16:03
-