常用的代码设置滑动是用
scrollToPosition()
smoothScrollToPosition()
这两个方法设置的recycleview会员滑动的效果,如果数据过多的话需要等待的时间过长,发现了一个新方法,没有动效但是滑动很快
((LinearLayoutManager)videoList.getLayoutManager()).scrollToPositionWithOffset(index,0)
0那里的偏移值不用管
另外是设置recycleVIew 一次滑动只切换一条,比较抖音滑动那种,具体代码如下
PagerSnapHelper snapHelper = new PagerSnapHelper(); snapHelper.attachToRecyclerView(videoList); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); videoList.setLayoutManager(linearLayoutManager);
PagerSnapHelper是系统自带的
本文介绍了如何通过新方法`scrollToPositionWithOffset`快速无动画滑动Recyclerview,以及如何设置单次切换一条数据以模仿抖音效果。还讨论了使用`PagerSnapHelper`进行布局管理的优化。
2614

被折叠的 条评论
为什么被折叠?



