Android中设置RecyclerView滑动到指定条目位置
1.滑动到指定条目的指定像素位置(item距离RecyclerView控件的左上角)
layoutManger.scrollToPositionWithOffset(指定条目, 像素位置);
2.滑动到指定条目的item底边位置
class BottomSmoothScroller extends LinearSmoothScroller {@Overrideprotected int getVerticalSnapPreference() {return SNAP_TO_END;//底边,还有其他位置属性}public BottomSmoothScroller(Context context) {super(context);}
}
使用:
BottomSmoothScroller smoothScroller = new BottomSmoothScroller(getContext());
smoothScroller.setTargetPosition(指定条目);
layoutManger.startSmoothScroll(smoothScroller);