TextView中的ellipsize不工作MAXLINES = 1 [英] TextView's ellipsize not working on maxLines = 1

查看:650
本文介绍了TextView中的ellipsize不工作MAXLINES = 1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实在想不通为什么,但我只能得到ellipsize在 MAXLINES = 2 工作等等。我说明显示了几句,然后一个长字符串,没有空格。

I really cannot figure out why, but I am only able to get ellipsize working on maxLines=2 and more. I am displaying a few words of description and then a long string with no spaces.

这是TextView的怎么是这样的:

This is how the TextView looks like:

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:textColor="#757575"
                android:text="@string/gcm_not_registered"
                android:maxLines="1"
                android:ellipsize="end"
                android:id="@+id/login_gcmRegistrationTextView"/>

我再编程设置文本给它,但根据MAXLINES限制,我得到两个不同的结果:

I then programatically set a text to it, but depending on the maxLines limitation, I get two different results:

这改变是 MAXLINES 的唯一一件事,为什么没有填写的第一张照片,以及行了?

The only thing that changed was the maxLines, why isn't the line filled in the first picture as well?

推荐答案

这是你所需要的:

android:ellipsize="end"
android:singleLine="true"

和删除这个属性:

android:maxLines="1"

这篇关于TextView中的ellipsize不工作MAXLINES = 1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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