我想在滚动时计算回收者视图项目的确切位置,我尝试过,但不知道为什么它没有得到我的确切位置。请看一下代码。
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (newState==RecyclerView.SCROLL_STATE_SETTLING){
int pos = layoutManager.findLastVisibleItemPosition();
if (pos>=5){
v2.setVisibility(View.GONE); // want to hide view when position 5 has just ended while scrolling upwards
}else {
v2.setVisibility(View.VISIBLE);//// want to show view when position 5 has just ended while scrolling downwards
}
}
}
});