问题
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,
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:
SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
Added in android.support library
来源:https://stackoverflow.com/questions/38778461/how-to-make-swipe-on-horizontal-recyclerview-bring-only-the-next-item-into-view