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

滑动快了 会有闪烁的情况 #24

Open
Sforllln opened this issue May 18, 2018 · 1 comment
Open

滑动快了 会有闪烁的情况 #24

Sforllln opened this issue May 18, 2018 · 1 comment

Comments

@Sforllln
Copy link

No description provided.

@Sforllln
Copy link
Author

Sforllln commented May 18, 2018

private class MyOnPageChangeListener extends ViewPager.SimpleOnPageChangeListener {
    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        //滑动时的透明度动画
        if (positionOffset > 0) {
            if (positionOffset < 0.1) positionOffset = 0;
            if (positionOffset > 0.9) positionOffset = 1;
            Log.d("postition", positionOffset + "---" + positionOffsetPixels + "--" + position);
            mTabViews.get(position).setIconAlpha(1 - positionOffset);
            mTabViews.get(position + 1).setIconAlpha(positionOffset);
        }
        //滑动时保存当前按钮索引
        mCurrentItem = position;
    }

@OverRide
public void onPageSelected(int position) {
super.onPageSelected(position);
// 这两行代码 去掉后 不会闪烁了.
// resetState();
// mTabViews.get(position).setIconAlpha(1.0f);
mCurrentItem = position;
}

}

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

1 participant