Reset Android textview maxlines

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

textView.setMaxLines(Integer.MAX_VALUE);

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

textView.setEllipsize(null);

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);
        }
       }
     }

You can find this in the source code of Android Open Source Project (AOSP)

https://source.android.com/source/downloading

If you do not want to download the source, you can view the source on a mirror like this one at github.

https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)