Android TabLayout: distribute evenly

I am considering a Google class that was used in a Google IO called SlidingTabLayout. Inside this class there is a method called setDistributeEvenly, which allows all these tabs to have uniform distribution on the screen - each tab has the same size: Align-Center SlidingTabLayout

I am trying to do the same with the official tabLayout class: https://developer.android.com/reference/android/support/design/widget/TabLayout.html

But there seems to be no method to evenly distribute all the tabs.

Am I missing something and is there a method inside the class that will allow me to do this?

+6
source share
1 answer

I read this tutorial to get the answer: http://panavtec.me/playing-with-the-new-support-tablayout/

Suppose you set tabLayout gravity:

tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); 

And do not make tabLayout scroll ( app:tabMode="scrollable" ), otherwise gravity fill will not work.

+19
source

All Articles