Michael A
Michael A

Reputation: 5840

Scroll RecyclerView on a button click

I want to be able to scroll right and left inside a RecyclerView when pressing right and left arrows in addition to the trivial scrolling when swiping

I know this method to scroll to speciffic location in the recycler view

linearLayoutManager.scrollToPositionWithOffset(2, 20);

But how can i achieve smooth right and left scrolling when pressing a button

Upvotes: 1

Views: 5562

Answers (1)

Neo
Neo

Reputation: 3584

use smoothScrollBy instead of scrollToPosition-

recyclerView.smoothScrollBy(dx, dy);

Hope it will help.

Upvotes: 2

Related Questions