How to make swipe on horizontal recyclerview bring

2019-07-21 02:19发布

I have a horizontal RecyclerView that shows 4 cards numbered 1-4. These cards take up the entire width of the screen so only 1 card can be fully visible at a time. The user is presented with the first card, when they swipe the card to the left like this,

enter image description here

the RecyclerView will scroll all the way to number 4. I don't want that.

I want the swipe to bring the next card (number 2) into the view

Similar to how Androids ViewPager works.

1条回答
闹够了就滚
2楼-- · 2019-07-21 02:38
SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);

Added in android.support library

查看更多
登录 后发表回答