I have ViewPager
with connected TabLayout
. If I use viewPager.setCurrentItem(position, true)
the correct tab on the tab layout is shown (TabLayout
automatically scrolls to the selected tab). But I want to use viewPager.setCurrentItem(position, false)
.In this case correct tab is selected (highlighted) but the problem is that TabLayout
doesn't scroll to this selected tab. It is hidden and I have to manual slide TabLayout
to see what tab is selected. Is it a bug? Can I manually force TabLayout
to scroll to the selected tab?
Update:
To be clear. My tab is properly selected and correct View is shown in ViewPager
when performing viewPager.setCurrentItem(position, true)
or viewPager.setCurrentItem(position, false)
. But with the second one, TabLayout
doesn't scroll so my selected (highlighted) Tab
is hidden.
Update 2:
I have opened the issue with a sample app: https://issuetracker.google.com/issues/72390853
Tab
does not move or theViewPager
is not showing the correctView
? – HorganTabLayout.Tab tab = mMainTabLayout.getTabAt(position); tab.select();
is what might be missing. Perhaps you could add all relevant code to your Post. Then we can step through your code to see exactly what is going on. – HorgansetCurrentItem
I'm changing tabs in myPagerAdapter
and callnotifyDataSetChanged()
. I have opened the issue with a sample app: issuetracker.google.com/issues/72390853 – Effeminize