`
huobengluantiao8
  • 浏览: 1034673 次
文章分类
社区版块
存档分类
最新评论

android 让多余的文字不显示

 
阅读更多

<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:ellipsize = "end"   省略号在结尾

android:ellipsize = "start"   省略号在开头

android:ellipsize = "middle" 省略号在中间

android:ellipsize = "marquee" 跑马灯

最好加一个约束android:singleline = "true"

当然也可以用代码语句

tv.setEllipsize(TextUtils.TruncateAt.valueOf("END"));

tv.setEllipsize(TextUtils.TruncateAt.valueOf("START"));

tv.setEllipsize(TextUtils.TruncateAt.valueOf("MIDDLE"));

tv.setEllipsize(TextUtils.TruncateAt.valueOf("MARQUEE"));

最好再加一个约束tv.setSingleLine(true);

不仅对于textview有此属性,对于editext也有,不过它不支持marquee

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics