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

针对ConsecutiveViewPager的源码问题 #299

Open
XXQAQ opened this issue Nov 23, 2023 · 1 comment
Open

针对ConsecutiveViewPager的源码问题 #299

XXQAQ opened this issue Nov 23, 2023 · 1 comment

Comments

@XXQAQ
Copy link

XXQAQ commented Nov 23, 2023

我在ConsecutiveViewPager的源码中看到了getCurrentScrollerView是

@Override
public View getCurrentScrollerView() {
    int count = getChildCount();
    for (int i = 0; i < count; i++) {
        View view = getChildAt(i);
        if (view.getX() == getScrollX() + getPaddingLeft()) {
            return view;
        }
    }
    return this;
}

这个地方我觉得很奇怪,为什么使用view.getX() == getScrollX() + getPaddingLeft()而不是以下的方式获取当前展示的View?

@Override
public View getCurrentScrollerView() {
    return getChildAt(getCurrentItem());
}
@donkingliang
Copy link
Owner

因为child的顺序是不确定的,item0对于的child view可能是getChildAt(0),也可能是getChildAt(1)或者其他

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