如何重置Android的TextView的maxlines的? [英] how to reset Android textview maxlines?

查看:6321
本文介绍了如何重置Android的TextView的maxlines的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个TextView是可折叠通过用户的接触。 当TextView的崩溃,我设置textview.setMaxLines(4); 如何清除我在我的扩展方法这种状态? 我只能想到电话setMaxLines()与价值一大批像10000。

I want a textview that is collapsable by user's touch. when the textview collapsed, I set textview.setMaxLines(4); how to I clear this state in my expand method? I can only think of call setMaxLines() with a value large number like 10000.

有没有实现这更好的方法呢?

Are there better ways to implement this?

感谢

推荐答案

其实,这样Android平台的确是由MAXLINE设置为Integer.MAX_VALUE。

Actually, the way android platform does that is by setting the MaxLine to Integer.MAX_VALUE.

textView.setMaxLines(Integer.MAX_VALUE);

此外,如果您使用的是Ellipsize,不要忘记设置为null。

also, if you are using Ellipsize, don't forget to set to null.

textView.setEllipsize(null);

只是检查如何Android框架做到这一点;)看setMaxLines(Integer.MAX_VALUE的);

just check how the android framework do just that ;) watch the setMaxLines(Integer.MAX_VALUE);

private void applySingleLine(boolean singleLine, boolean applyTransformation) {
    mSingleLine = singleLine;
    if (singleLine) {
        setLines(1);
        setHorizontallyScrolling(true);
        if (applyTransformation) {
            setTransformationMethod(SingleLineTransformationMethod.getInstance());
        }
       } else {
            setMaxLines(Integer.MAX_VALUE);
            setHorizontallyScrolling(false);
            if (applyTransformation) {
                 setTransformationMethod(null);
        }
       }
     }

这篇关于如何重置Android的TextView的maxlines的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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