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);
网友评论