RecylerView滚动到指定位置的方法


public class TopSmoothScroller extends LinearSmoothScroller {
    TopSmoothScroller(Context context) {
        super(context);
    }
    @Override
    protected int getHorizontalSnapPreference() {
        return SNAP_TO_START;//具体见源码注释
    }
    @Override
    protected int getVerticalSnapPreference() {
        return SNAP_TO_START;//具体见源码注释
    }
}

然后调用LinearLayoutManager的startSmoothScroll即可

final TopSmoothScroller mScroller = new TopSmoothScroller(getActivity());
mScroller.setTargetPosition(integer);
mManager.startSmoothScroll(mScroller);

你可能感兴趣的:(RecylerView滚动到指定位置的方法)