2
如何让滚动回滚视图在滚动时在每个项目的准确开始处滚动,例如在谷歌播放中的horizontal recyclerview。android recyclerview准确地滚动到项目的开始
如何让滚动回滚视图在滚动时在每个项目的准确开始处滚动,例如在谷歌播放中的horizontal recyclerview。android recyclerview准确地滚动到项目的开始
,如果你想实现谷歌Play应用线性捕捉功能外,你可以参考本教程RecyclerView Snapping
它详细阐述了实现它
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
rvPreview.setLayoutManager(linearLayoutManager);
rvPreview.setItemAnimator(new DefaultItemAnimator());
,并使用此
SnapHelper snapHelper = new LinearSnapHelper();
snapHelper.attachToRecyclerView(rvPreview);
你可能会考虑使用'ViewPager' –
'android.support.v7.widget.LinearSnapHelper'? – pskink
@pskink谢谢,我不知道snaphelper。现在你知道了 – rezandro