TextView我的布局中有一个wrap_content位于layout_width. 它限制为最多 15 个字符,所以我使用maxLength.
我需要TextView用 3 个点 (...) 来结束它,只有当我layout_width在 dp 中给出固定大小时才会发生这种情况,这是我不想做的事情。
我知道通过在第 15 个字符之后修剪字符串然后添加 3 个点以编程方式是可能的,但我更喜欢通过 XML 来做到这一点。
知道如何用 3 个点结束文本并将其保留为 wrap_content 吗?
<TextView
    android:id="@+id/inbox_contactName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:lines="1"
    android:maxLines="1"
    android:ellipsize="end"
    android:singleLine="true"
    android:maxLength="15"
    android:textColor="#0670b4"
    android:textSize="16sp" />

