Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make tab title alignment to left in TabLayout in Android

I can't seem to align my tab titles to the left, inside my TabLayout. At the moment, the titles are centered. Here is what I want to achieve.

And this is what I have at the moment. The code I'm using is as follows:

<android.support.design.widget.TabLayout
    android:id="@+id/tabs"
    app:tabGravity="fill"
    app:tabMode="fixed"
    app:tabTextColor="@color/white"
    app:tabSelectedTextColor="@color/white"
    app:tabIndicatorColor="@color/white"
    android:background="@color/slate_grey"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
</android.support.design.widget.TabLayout>
like image 996
Naman Avatar asked Aug 25 '16 10:08

Naman


3 Answers

add app:tabMode="scrollable" to your <TabLayout.../> and don't forget to add xmlns:app="http://schemas.android.com/apk/res-auto" too.

For more info check out https://developer.android.com/reference/android/support/design/widget/TabLayout.html

like image 178
Elvis Chweya Avatar answered Nov 19 '22 13:11

Elvis Chweya


Just set the TabLayout width to wrap_content. Done.

like image 35
kopikaokao Avatar answered Nov 19 '22 13:11

kopikaokao


Try app:tabPaddingEnd="" very late answer but hope it will help someone

like image 1
Mohammed Rousul Avatar answered Nov 19 '22 15:11

Mohammed Rousul