How do I display a fixed number of tabs at once in Android Material Design tabs?… here is a solution to the problem.
How do I display a fixed number of tabs at once in Android Material Design tabs?
I used the Android Design Support Library and implemented tabs in my Android app using tablayout, fragments, and viewpager. Tab swiping works fine. But when I add more tabs (say 7), the tabs reduce the width and adjust themselves. How do I display only 3 tabs at a time and show the next three tabs when the user slides from tab 3 to tab 4?
Solution
In your MainActivity
ViewPager mpager;
TabPageAdapter adapter = new TabPageAdapter(getSupportFragmentManager(), list);
mtabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
mpager.setOffscreenPageLimit(list.size());
mpager.setAdapter(adapter);
In your xml TabLayout settings
app:tabMode="scrollable"