How to disable the TextView maxLines programmatically?

前端 未结 4 1567
栀梦
栀梦 2021-02-04 23:55

I\'m having a hard time reseting the maxLines attribute of a TextView programmatically.

Just tried setting to 0 and it doesn\'t wo

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-05 00:27

    As there isn't yet an approved answer - the proper way to reset the maxlines property of the TextView is:

    textView.setMaxLines(Integer.MAX_VALUE);

    As per Valdemar's comment and this stackoverflow answer. Using -1 will cause an ArrayIndexOutOfBoundsException.

    Keep in mind only END and MARQEE setEllipsize() settings will be respected for maxlines >= 2 according to the documentation:

    If setMaxLines(int) has been used to set two or more lines, END and MARQUEE* are only supported (other ellipsizing types will not do anything).

提交回复
热议问题