如何在水平RecyclerView上滑动,仅将下一个项目带入视图-Android [英] How to make swipe on horizontal recyclerview bring only the next item into view - Android
本文介绍了如何在水平RecyclerView上滑动,仅将下一个项目带入视图-Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个水平的 RecyclerView
,其中显示了4张编号为1-4的卡.这些卡占据了屏幕的整个宽度,因此一次只能完全看到1张卡.当用户向左滑动卡片时,会看到第一张卡片,
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,
RecyclerView
将一直滚动到数字4.我不想要.
the RecyclerView
will scroll all the way to number 4. I don't want that.
我希望滑动将下一张卡片(第2张)带入视图
类似于Android的 ViewPager
的工作方式.
Similar to how Androids ViewPager
works.
推荐答案
SnapHelper snapHelper = new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
已添加到android.support库中
Added in android.support library
这篇关于如何在水平RecyclerView上滑动,仅将下一个项目带入视图-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文