0

In a ListView, getListView().setSelection(n); is used for a direct scroll and getListView().smoothScrollToPosition(n); is used for a smooth scroll.

Is this possible in a RecyclerView?

Phil Miller
  • 36,389
  • 13
  • 67
  • 90
Erick Velasco
  • 121
  • 5
  • 13
  • Why not read the doc:https://developer.android.com/intl/zh-cn/reference/android/support/v7/widget/RecyclerView.html ? – zzy Jul 21 '15 at 02:21

1 Answers1

4

You'll have to use scrollToPositionWithOffset.

//Scroll item 2 to 20 pixels from the top
linearLayoutManager.scrollToPositionWithOffset(2, 20);

This question was answered before.

Community
  • 1
  • 1
Tin Megali
  • 771
  • 5
  • 25