Search code examples
androidindicator

tab indicator not moving when swiping but moves on selection


I have a main activity with 3 tabs,when i swipe the tabbed indicator doesn't move but the layout changes while selecting a tab the indicator moves and the layout changes too.


Solution

  • 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();
                    }
                });