Question

I'm using ViewPagerIndicator http://viewpagerindicator.com/

The theme specifies a style, which is being used (I can change the text colour in the style and see it affect the tab text)

<style name="TabText" parent="Widget.TabPageIndicator.Text">
  <item name="android:textColor">@color/white</item>
  <item name="android:textSize">14sp</item>
  <item name="android:ellipsize">end</item>
</style>

I want to control how longer tab names are handled. I want to trial using wrap_content (i.e. so tabs resize to wrap the text width) and I also want to trial using ellipsizing on long text (i.e. tabs all the same width, but if the title is too long, it ellipsizes).

enter image description here

The ellipsizing works on older devices (e.g. the Nexus One)

enter image description here

But on ICS the ellipsizing is not working, and the title just truncates

How do I control the width & ellipsizing of tab text in VPI?

(on a related note I find long text by default wraps in VPI, so I'm search-replacing spaces with non-breaking spaces to stop that as singleLine=true in the style causes VPI to throw a cast exception)

Was it helpful?

Solution

The solution appears to be simple, to add singleLine=true" to the style. It seems the truncation was not truncation, but actually wrapping.

Adding this attribute no longer causes a cast exception in VPI in my project, so I can only assume some other factor was involved in the cast exception I was seeing previously.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top