Android的,如何限制TextView的宽度(以及在文本的末尾添加三个点)? [英] Android, How to limit width of TextView (and add three dots at the end of text)?

查看:473
本文介绍了Android的,如何限制TextView的宽度(以及在文本的末尾添加三个点)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我要限制它的字符的文本视图。其实,我能做到这一点,但我正在寻找的是如何在字符串末尾添加三个点(...)的东西。这其中显示的文字有继续。这是我的XML,但没有点虽然它限制了我的文字。

 <的TextView
        机器人:ID =@ + ID / tvFixture
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_toLeftOf =@ ID / ivFixture_Guest
        机器人:文本=@字符串/ test_06
        机器人:行=1
        机器人:EMS =3
        机器人:重力=右
        风格=@风格/ simpletopic.black
        机器人:ellipsize =结束/>
 

解决方案

再添加一个属性安卓SINGLELINE =真正的在你的TextView

I have a text view that i want to limit characters of it. Actually, I can do this but the thing that i'm looking for is how to add three dots (...) at the end of string. This one shows the text has continue. This is my XML but there is no dots although it limit my text.

<TextView 
        android:id                      = "@+id/tvFixture"
        android:layout_width            = "wrap_content"
        android:layout_height           = "wrap_content"
        android:layout_toLeftOf         = "@id/ivFixture_Guest"
        android:text                    = "@string/test_06"
        android:lines                   = "1"
        android:ems                     = "3"
        android:gravity                 = "right"
        style                           = "@style/simpletopic.black" 
        android:ellipsize="end"/>

解决方案

Add one more property android:singleLine="true" in your Textview

这篇关于Android的,如何限制TextView的宽度(以及在文本的末尾添加三个点)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆