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.

Upvotes: 3

Views: 1976

Answers (2)

Sagar Pithiya
Sagar Pithiya

Reputation: 56

You can also do like

tabLayout.setupWithViewPager(viewPager);

Upvotes: 0

Ognian Gloushkov
Ognian Gloushkov

Reputation: 2659

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

Upvotes: 5

Related Questions