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

上拉后,下拉到底部 上面有空白 #42

Open
lizhen0211 opened this issue Jan 22, 2019 · 2 comments
Open

上拉后,下拉到底部 上面有空白 #42

lizhen0211 opened this issue Jan 22, 2019 · 2 comments

Comments

@lizhen0211
Copy link

上拉后,下拉到底部 上面有空白条
screenshot_20190122-150251

@lizhen0211
Copy link
Author

screenshot_20190122-151002

@lucidreamiss
Copy link

这时因为这里onNestedPreScroll处理下拉时,发生了scrollY越界,在showTop时,应当判断当前dy是否超过了scrollY的范围
以下是修复代码,我拿kt写的

 override fun onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray) {
        printStack()

        val hiddenTop = dy > 0 && scrollY < mTopViewHeight
        val showTop = dy < 0 && scrollY >= 0f && !target.canScrollVertically(-1)

        if (hiddenTop) {
            scrollBy(0, dy)
            consumed[1] = dy
        }
        if (showTop) {
            scrollBy(0, -min(scrollY, abs(dy)))
            consumed[1] = -min(scrollY, abs(dy))
        }
    }

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