当前位置: 代码迷 >> Android >> android 多余文字展示省略号
  详细解决方案

android 多余文字展示省略号

热度:98   发布时间:2016-05-01 16:03:51.0
android 多余文字显示省略号

果然,看了 api google 不但做了,而且做的更好,

看到 EditText 里有个 setEllipsize 方法

public void setEllipsize (TextUtils.TruncateAt where)

方法参数 TextUrils.TruncateAt?? :

看到了吧,不但提供 后面加 ... 前面,中间 也可以,~~~

Summary

Enum Values
TextUtils.TruncateAt ??? END
TextUtils.TruncateAt ?? MARQUEE
TextUtils.TruncateAt ?? MIDDLE
TextUtils.TruncateAt ??? START

哦耶,搞定。

——————————

可能你要问 如果?? layout 的 xml 文件里 怎么 弄呢?

public static final int ellipsize

Since: API Level 1

Where to ellipsize text.

Must be one of the following constant values.

ConstantValueDescription
none0?
start1?
middle2?
end3?
marquee4?

?

Constant Value: 16842923 (0x010100ab)
<TextView
?? android:id="@+id/item_text"
?? android:layout_width="wrap_content"
?? android:layout_height="wrap_content"
?? android:textSize="16sp"
?? android:singleLine="true"
??android:ellipsize="end"
?? >
?? </TextView>

这里 要强调两点
一定要注意,不然?? 你就无缘看到 谷歌给你 加上的 ... 了

android:layout_width="wrap_content"?????? 这个是?? 必须?? 的

android:singleLine="true"??????这个不必须, 因为 系统可能会两行 然后 加...
????????????????????????????????但是 一会儿一行,一会儿两行的 界面,估计不太能让人接受。

  相关解决方案