user6419910 user6419910 - 4 months ago 14
Android Question

Setting width of tabs in android.support.design.widget.TabLayout?

I am using tabs for my Viewpager, and this is the XML right now:

<android.support.design.widget.TabLayout
android:id="@+id/viewpager_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed"/>


They look great but I want to be able to have more tabs and not have everything squish on the screen. However I don't like switching to scrollable tabMode because then everything flattens out and looks messy. How can I set the width of the individual tabs?

Answer Source

TabLayout does not provide the attributes for particular tab's fixed width. But you can set min and max width.

tabMinWidth and tabMaxWidth

https://developer.android.com/reference/android/support/design/widget/TabLayout.html