Recycleview滑动的距离(LinearLayout)

2018-07-25  本文已影响9人  喜爱滴小麦芽
 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的高度一致使用
上一篇下一篇

猜你喜欢

热点阅读