简体   繁体   中英

tab indicator not moving when swiping but moves on selection

我有一个带有3个标签的主要活动,当我滑动标签指示器不移动但布局改变时,选择标签指示器移动,布局也改变。

Make sure you have a OnPageChangeListener attached to your ViewPager

mViewPager.setOnPageChangeListener(
            new ViewPager.SimpleOnPageChangeListener() {
                @Override
                public void onPageSelected(int position) {
                    mTabs.getTabAt(position).select();
                }
            });

You can also do like

tabLayout.setupWithViewPager(viewPager);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM