Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Design Support Library: TabLayout tabs text in single line [duplicate]

I want to put tabs text(max 8 chars) in single line

enter image description here

I added a custom style to TabLayout element

<style name="MyCustomTabLayout" parent="Widget.Design.TabLayout">
    <item name="tabTextAppearance">@style/MyCustomTabTextAppearance</item>
</style>
<style name="MyCustomTabTextAppearance" parent="TextAppearance.Design.Tab">
    <item name="android:maxLines">1</item>
    <item name="android:singleLine">true</item>
</style>

Still it does not work out. I also tried

 <android.support.design.widget.TabLayout
  app:tabTextAppearance="@style/MyCustomTabTextAppearance"
  ..
  ..
  />
like image 946
Harsh Avatar asked Jan 01 '16 10:01

Harsh


1 Answers

Just add app:tabMode="scrollable" to TabLayout;

<android.support.design.widget.TabLayout 
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_tabs" 
android:layout_width="match_parent" 
app:tabMode="scrollable"
android:layout_height="wrap_content" /> 
like image 79
tiny sunlight Avatar answered Nov 13 '22 11:11

tiny sunlight