1、列表滚动指定的位置
recy_question为recyclerview的id
recy_question.scrollToPosition(3);
2、希望recyclerview可以像viewpaper一个item占满整个屏幕
new PagerSnapHelper().attachToRecyclerView(recy_question);
显示下标的话
recy_question.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
if (newState ==SCROLL_STATE_IDLE){
RecyclerView.LayoutManager lm =recy_question.getLayoutManager();
if(lminstanceof LinearLayoutManager){
LinearLayoutManager ll = (LinearLayoutManager) lm;
int position = ll.findLastVisibleItemPosition();
tvTitle.setText((position+1) +"/" +count);
}
}
super.onScrollStateChanged(recyclerView, newState);
}
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
}
});
但是第一次需要自己写一个默认的下标