常用的代码设置滑动是用
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是系统自带的