android – TextView:让它截断而不考虑单词之间的空格

如何将TextView配置为在单词的中间截断?

因此,如果我有text =“Some Text”,我希望它显示为“Some Te”,假设宽度支持.

相反,我所看到的是“一些”;即使有足够的空间容纳更多的角色,它也会截断整个单词“Text”.

解决方法

这对我有用:
<TextView 
    android:layout_width="80px"
    android:layout_height="wrap_content"
    android:text="Some text"
    android:background="#88ff0000"
    android:singleLine="true"
    android:ellipsize="marquee"/>

或者最后用“……”:

<TextView 
    android:layout_width="80px"
    android:layout_height="wrap_content"
    android:text="Some text"
    android:background="#88ff0000"
    android:singleLine="true"
    />

虽然使用android:行不起作用:

<TextView 
    android:layout_width="80px"
    android:layout_height="wrap_content"
    android:text="Some text"
    android:background="#88ff0000"
    android:lines="1"
    android:ellipsize="marquee"/>

这很可能是一个错误,我相信我已经看到了一些错误报告.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...