Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RecyclerView: Go to a position not scroll to

Is there a way with the RecyclerView to go directly to a nominated position rather than scroll to it. (If the distance to the target is large and the item layout complex, scrolling can take an acceptable amount of time.)

like image 351
Kevin Gilbert Avatar asked Nov 06 '15 02:11

Kevin Gilbert


2 Answers

Use ScrollToPosition to go directly to a position on RecyclerView

recyclerView.scrollToPosition(your_position)

http://developer.android.com/reference/android/support/v7/widget/RecyclerView.html#scrollToPosition(int)

like image 82
Libin Avatar answered Nov 07 '22 17:11

Libin


You can use recyclerView.scrollToPosition(position) instead of smoothScrollToPosition(position).

like image 29
Abd Qadr Avatar answered Nov 07 '22 16:11

Abd Qadr