public int getScrollYDistance() {
LinearLayoutManager layoutManager = (LinearLayoutManager) rv.getLayoutManager();
int position = layoutManager.findFirstVisibleItemPosition();
View firstVisiableChildView = layoutManager.findViewByPosition(position);
int itemHeight = firstVisiableChildView.getHeight();
return (position) * itemHeight - firstVisiableChildView.getTop();
}
每个item的高度一致使用
网友评论