Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed Item Height obtain that would be a problem? #122

Open
negier opened this issue Mar 3, 2024 · 2 comments
Open

fixed Item Height obtain that would be a problem? #122

negier opened this issue Mar 3, 2024 · 2 comments

Comments

@negier
Copy link

negier commented Mar 3, 2024

FastScrollRecyclerView#updateThumbPosition

rowCount * scrollPosState.rowHeight

Because some itemView height is not same. I like your smooth effect, but I haven't use your code. So this question only give you look.

@negier
Copy link
Author

negier commented Mar 4, 2024

I find you use fixed ItemHeight to calculate AllHeight, and you use

View view = recyclerView.getChildAt(0);
linearLayoutManager.getDecoratedTop(view); 

But I find some code in internet, may be should be better:

            int range = 0;
            int temp = recyclerView.computeVerticalScrollRange();//整体的高度,注意是整体,包括在显示区域之外的 会动态变化
            if (temp > range) {
                range = temp;
            }
            int offset = recyclerView.computeVerticalScrollOffset();//已经向下滚动的距离,为0时表示已处于顶部。
            int extent = recyclerView.computeVerticalScrollExtent();//RecycleView显示区域的高度。
            float proportion = (float) (offset * 1.0 / (range - extent));//滑动比例

You can use this code optimize your library, I recommand you put this code in onPreDraw listener inner.

@Danielnajarn
Copy link

You can use this code optimize your library, I recommand you put this code in onPreDraw listener inner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants