【发布时间】:2016-01-25 03:05:48
【问题描述】:
我知道这个问题已经被问过多次,但我无法使用可用的解决方案来解决我的问题。
我应用了其他堆栈溢出线程上可用的所有解决方案。
要求:
如果字符串长度超过 140,则只显示 140 个字符,最后添加“..”。 如果字符串少于 140 个字符,则最后不需要附加“..”。
我尝试过的:
<TextView
android:id="@+id/tvIssueBody"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLength="140"
android:paddingBottom="5dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/detail_text_size"/>
我已经尝试了上面的代码,但它不起作用,我也尝试了所有其他属性混合,但它不起作用。
我应该与str.subString(0,141) 选项有关吗?没有办法使用 textview 属性限制 140 个字符?
感谢所有提前。任何帮助将不胜感激。
【问题讨论】:
标签: android android-layout android-widget textview