TextView的ellipsize高度智慧 [英] TextView ellipsize height wise

查看:150
本文介绍了TextView的ellipsize高度智慧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android的任何相等于:ellipsize (其中ellipsizes文本太长在x轴)的文本太长在y轴上?我必须是一个固定的高度一个TextView,但文内通常是太长,全部装入,我想它得到削减一半之前停止。

Is there any equivalent of android:ellipsize (which ellipsizes text that is too long on the x-axis) for text that is too long on the y-axis? I have a TextView which must be a fixed height, however the text inside of it is usually too long to all fit in, and I would like it to stop before getting cut in half.

我不想将的android:MAXLINES 属性,这样我可以支持多种屏幕尺寸

I do not want to set the android:maxLines attribute so that I can support multiple screen sizes.

我也使用其认为...

I have also considered using...

int maxLines = (int) textView.getHeight() / textView.getLineHeight();
textView.setMaxLines(maxLines);

...,但是这可能会导致一个问题,因为的在文本中的标记可能会导致个别线路会比这个高度更高或更短。

编辑:我在文中有一半在这里使用一个滚动型为prevent切割,但我宁愿这是一个preVIEW,与下方的按钮,用户点击进入查看全文

I could use a ScrollView here to prevent the cutting in half of the text, but I would rather this be a preview, with a button below for the user to click to view the entire text.

推荐答案

尝试手动设置ellipsize,使用 setEllipsize(TextUtils.TruncateAt哪里),并确定要在其中文本被截断。

Try setting the ellipsize manually, using setEllipsize(TextUtils.TruncateAt where), and defining where you want the text to be cut off.

这篇关于TextView的ellipsize高度智慧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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