背景:水平滚动的List,一项Item占满页面宽度,相当于数量不定的选项卡,每个选项卡占满一页,左右滑动时,如何限制一次只能滑动一个Item
步骤:
1. 水平滚动布局
linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); xxxRecyclerView.setLayoutManager(linearLayoutManager); xxxAdapter = new SlideAdapter(mList); xxxRecyclerView.setAdapter(xxxAdapter);
2. 设定单次滑动一次Item(加在setAdapter后面)
PagerSnapHelper snapHelper = new PagerSnapHelper(); snapHelper.attachToRecyclerView(xxxRecyclerView);
标签:xxxRecyclerView,List,Item,linearLayoutManager,new,滑动,Android,单次 From: https://www.cnblogs.com/uoky/p/18236515