我必须在 TextView 中的文本末尾添加 3 个点。我的 textView 位于惰性列表适配器中,因此内容经常更改。textview 中仅显示两行。
例如假设文本是
abcdefghigdddddddd dddddddddddddddddddd
结果应该是
abcdefghigdddddddd dddddddddddddddd...
我知道我应该使用 .replace("...","");
但是如何总是注销最后三个单词?
我的 TextView 如下
holder.title.setText(Html.fromHtml(a.name));
其中a.name是要设置的数据。
最佳答案
您可以向 TextView 添加“省略号”属性,并指定 TextView 只有一行。它可能看起来像这样:
<TextView
android:id="@+id/text_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1" />
关于java - 在动态文本android末尾添加三个点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15615984/