hackware1993 / MagicIndicator

A powerful, customizable and extensible ViewPager indicator framework. As the best alternative of ViewPagerIndicator, TabLayout and PagerSlidingTabStrip —— 强大、可定制、易扩展的 ViewPager 指示器框架。是ViewPagerIndicator、TabLayout、PagerSlidingTabStrip的最佳替代品。支持角标,更支持在非ViewPager场景下使用(使用hide()、show()切换Fragment或使用setVisibility切换FrameLayout里的View等),http://www.jianshu.com/p/f3022211821c

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

能支持下 viewpage2?

lastzhou opened this issue · comments

能支持下 viewpage2?

点开 ViewPagerHelper 的代码你就知道该怎么做了

commented

点开 ViewPagerHelper 的代码你就知道该怎么做了
binding.viewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@OverRide
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
binding.mMagicIndicator.onPageScrolled(position, positionOffset, positionOffsetPixels);
}

        @Override
        public void onPageSelected(int position) {
            binding.mMagicIndicator.onPageSelected(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
            binding.mMagicIndicator.onPageScrollStateChanged(state);
        }
    });

这样会有一个问题就是 点击你的
image
就会出现指示器跳动每个标题都会停顿

很简单,调用viewPager.setCurrentItem(index,false)就可以