xmuSistone / VegaLayoutManager

√A customized LayoutManager - fade and shrink the head itemView when scrolling.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

很强大的库,感谢分享,能不能扩展下呢

thundeGG opened this issue · comments

比如可以跟LinearLayoutMangear一样往上滑,但是当前显示的第一个item跟现在一样缩小

commented

这个。。怕是需要后来人来扩展了

/**
* 计算可滑动的最大值
*/
private void computeMaxScroll() {
maxScroll = locationRects.get(locationRects.size() - 1).bottom - getHeight();
if (maxScroll < 0) {
maxScroll = 0;
return;
}

    int itemCount = getItemCount();
    int screenFilledHeight = 0;
    for (int i = itemCount - 1; i >= 0; i--) {
        Rect rect = locationRects.get(i);
        screenFilledHeight = screenFilledHeight + (rect.bottom - rect.top);
        if (screenFilledHeight > getHeight()) {
            int extraSnapHeight = getHeight() - (screenFilledHeight - (rect.bottom - rect.top));
            maxScroll = maxScroll + extraSnapHeight;
            break;
        }
    }
}

这块我想让它的最大滑动距离到Recyclerview的底部就不能滑,该怎么改 TAT

commented

@7hunder 你这样改,是可以的。最大滑动到底部,如果达不到snap的要求,snap在最后一个item便不工作了。

改了半天还是没太明白你这个maxScroll 是怎么算的 TAT

commented

代码设计是你在绑定Adapter或者notifyChange的时候,每一个item的位置、高度,都给你计算好并保存到rect中。maxScroll就是你最大滑动的值。只需要通过最后一个view对应的rect就可以算出来。

最后一个view对应的rect的bottom值吗

亲,我又来了,能扩展成横向的吗😂😂

commented

you can see https://github.com/Victor2018/VegaLayoutManager support horizontal & vertical scroll by kotlin

commented

亲,我又来了,能扩展成横向的吗😂😂

you can see https://github.com/Victor2018/VegaLayoutManager support horizontal & vertical scroll by kotlin