Search code examples
androidkotlintabsandroid-viewpagerandroid-tablayout

Fixed number of tabs per page in TabLayout


I am using scrollable TabLayout with a ViewPager.
I want to make sure that at any given time I have 7 tabs displayed per page. Even if the total number of tabs is 10, I want to have 7 per page, and scroll to expose the other 3.
I can't find a property to control the number of tabs displayed.


Solution

  • Eventually what worked for me was to calculate the desired size of each cell to get the total amount of tabs that I needed per page and set app:tabMaxWidth inside android.support.design.widget.TabLayout