ViewPagerIndicator标签 - 控制文本样式 [英] ViewPagerIndicator tabs - control over text styling

查看:371
本文介绍了ViewPagerIndicator标签 - 控制文本样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用ViewPagerIndicator http://viewpagerindicator.com/

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>

我要控制更长的标签名称的处理方式。我想试用WRAP_CONTENT(即让标签调整换行文本的宽度),我也想试使用ellipsizing上长文本(即标签页都是一样的宽度,但如果标题过长,ellipsizes)。

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).

在ellipsizing适用于旧设备(如Nexus One的)

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

但在ICS的ellipsizing不工作,和标题只是截断

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

我如何控制宽度和放大器; ellipsizing标签文字的VPI?

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

(上一个相关的说明,我觉得长的文本在默认VPI包装,所以我用非中断空格停止,由于单线=在样式true会导致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)

推荐答案

该解决方案看似简单,以单线=真添加到风格,似乎截断并不截断,但实际上包装。

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

添加此属性不再导致转换异常的VPI在我的项目,所以我只能假设其他因素参与中投例外,我是看到previously。

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.

这篇关于ViewPagerIndicator标签 - 控制文本样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆