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

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

问题描述

我有一个 TextView 我想限制它的字符.实际上,我可以做到这一点,但我正在寻找的是如何在字符串末尾添加三个点 (...).这表明文本一直在继续.这是我的 XML,但没有点,尽管它限制了我的文本.

I have a TextView 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"/>

推荐答案

已弃用:

在你的 Textview 中再添加一个属性 android:singleLine="true"

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

更新:

android:ellipsize="end" 
android:maxLines="1"

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

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