如果TextSize在android中更多,则放三个点

时间:2013-08-02 12:17:43

标签: android xml

在Android中,如果长度大于某个限制,我怎么能通过在文本的末尾放置三个点来限制TextView的宽度?

2 个答案:

答案 0 :(得分:10)

将此代码放入TextView

android:ellipsize="end"
android:singleLine="true"   // if you want 3 dots for single line, add this.
android:maxLines="2" // if you want 3 dots after two lines, add this.

答案 1 :(得分:1)

为此目的使用ellipsize属性。

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/text_mytext"
    android:ellipsize="end"
    android:singleLine="true"
    />

与上述类似的代码应该适合您。同时设置maxLines=1