如何设置MAXLINES一个TextView和ellipsize同时 [英] How to set maxLines and ellipsize of a TextView at the same time

查看:254
本文介绍了如何设置MAXLINES一个TextView和ellipsize同时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想限制我的文字,以获得最大的5行,所以我所做的:

I want to limit my text view to have maximum of 5 lines, so I did:

<TextView
    android:id="@+id/text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"  
    android:maxLines="5" />

但是,当我尝试将其配置加上'......当文字被截断,我想补充的android:ellipsize =结束。我也看到了......但后来我的TextView只有2的最高线,而不是5。

But when I try to configure it to add '...' when the text is truncated, I add android:ellipsize="end". I do see the ... but then my TextView only has a max line of 2, instead of 5.

您可以请建议我该怎么做的最多5个行的文本视图,并添加...时,它会被截断?

Can you please suggest how can I make the text view of maximum line of 5 and add '...' when it get truncated?

感谢你。

推荐答案

Progrmatically,你可以使用:

Progrmatically, you can use:

your_text_view.setEllipsize(TextUtils.TruncateAt.END);
your_text_view.setMaxLines(4);
your_text_view.setText("text");  

这篇关于如何设置MAXLINES一个TextView和ellipsize同时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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