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

ViewPager宽度变化时位置错误 #6

Open
wurensen opened this issue Aug 6, 2020 · 1 comment
Open

ViewPager宽度变化时位置错误 #6

wurensen opened this issue Aug 6, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@wurensen
Copy link
Owner

wurensen commented Aug 6, 2020

原因:ViewPager的onSizeChanged中进行了滚动位置的重新计算

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);

        // Make sure scroll position is set correctly.
        if (w != oldw) {
            recomputeScrollPosition(w, oldw, mPageMargin, mPageMargin);
        }
    }
@wurensen wurensen added the bug Something isn't working label Aug 6, 2020
@wurensen
Copy link
Owner Author

自定义的GraceViewPager能够很好的解决宽度变化的问题,在不使用GraceViewPager而是使用原生ViewPager通过添加支持的方式,在设置了pageMargin的情况下去逆向计算调用了recomputeScrollPosition“纠正”前的scrollX值,会存在计算误差。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant