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一起使用,偶发tab和content错位 #321

Open
lyx0224 opened this issue Jan 20, 2018 · 2 comments
Open

和viewpager一起使用,偶发tab和content错位 #321

lyx0224 opened this issue Jan 20, 2018 · 2 comments

Comments

@lyx0224
Copy link

lyx0224 commented Jan 20, 2018

场景:MainActivity使用了TabStrip + ViewPager布局。lanchmode=singleTask。从某个子页面回到MainActivity时候,偶发错位。

@lixiaote
Copy link

lixiaote commented Mar 6, 2019

楼主这个问题解决了吗,我也遇到这个问题了

@lixiaote
Copy link

lixiaote commented Mar 6, 2019

it is a bug.
you can fix it by adding this line to the PagerSlidingTabStrip.java

加上这行就可以了 currentPositionOffset = 0;//source line number 220

getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
@Override
public void onGlobalLayout() {

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        getViewTreeObserver().removeGlobalOnLayoutListener(this);
    } else {
        getViewTreeObserver().removeOnGlobalLayoutListener(this);
    }

    currentPosition = pager.getCurrentItem();
    currentPositionOffset = 0;//source line number 220
    scrollToChild(currentPosition, 0);
}

});

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