美文网首页
Recycleview滑动的距离(LinearLayout)

Recycleview滑动的距离(LinearLayout)

作者: 喜爱滴小麦芽 | 来源:发表于2018-07-25 14:11 被阅读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的高度一致使用
    

    相关文章

      网友评论

          本文标题:Recycleview滑动的距离(LinearLayout)

          本文链接:https://www.haomeiwen.com/subject/kxupmftx.html