Avoid word wrap (and "...") in long tab titles using ViewPager Tab [landscape]

713 views Asked by At

How do I avoid word wrap and incomplete tab titles ( like the three '...') in Tabs using ViewPager

See screenshot below:

enter image description here

UPDATE

When I set the following in styles.xml:

<style name="MyTabTextStyle" parent="Base.Widget.AppCompat.ActionBar.TabText">
    <item name="android:maxLines">1</item>
    <item name="android:width">80dp</item>
</style>

it partly works when I DO NOT ADD A LOGO in ActionBarStyle:

<style name="MyActionBarStyle" parent="Widget.AppCompat.ActionBar.Solid">

enter image description here

UPDATE 2 - PROBLEM STILL EXIST WITH LOGO

This is the result, when I use ActionBarStyle to add a logo

enter image description here

Thank you in advance

1

There are 1 answers

0
stan0 On BEST ANSWER

The problem is in the width of your TabText widget:

<item name="android:width">80dp</item>

As you see sometimes 80dp is just enough for your content, but sometimes - it's not. You should avoid using fixed width or height. Instead you can use the wrap_content (wide or high enough to fit the content) and match_parent (match the parent size exactly, possibly leaving a lot of "blank space") values.