我很难重置maxLines
的属性TextView
以编程方式。
刚刚尝试设置为0
但它不起作用。-1
使应用程序崩溃。我可以使用更简单的解决方法并设置maxLines
to 5000
但我不想那样做。
有什么想法如何做到这一点吗?
UPDATED
好吧,我发现了一个问题..我也设置了椭圆尺寸...我将使用以下解决方法:
TextView questionDetail = (TextView) mQuestionDetailHeader.findViewById(R.id.desc);
questionDetail.setText(mCurrentQuestion.getQuestion());
questionDetail.setMaxLines(Integer.MAX_VALUE); //As in the android sourcecode
questionDetail.setEllipsize(null);
由于尚未得到批准的答案 - 重置 TextView 的 maxlines 属性的正确方法是:
textView.setMaxLines(Integer.MAX_VALUE);
As per Valdemar https://stackoverflow.com/users/766150/valdemar的评论和这个堆栈溢出答案 https://stackoverflow.com/a/6438524/740474。使用 -1 会导致ArrayIndexOutOfBoundsException
.
只记住END
and MARQEE
根据 maxlines >= 2 的设置,将遵守 setEllipsize() 设置文档 http://developer.android.com/reference/android/widget/TextView.html#setEllipsize%28android.text.TextUtils.TruncateAt%29:
如果 setMaxLines(int) 已用于设置两条或多条线,则 END 和
仅支持 MARQUEE*(其他椭圆化类型不支持)
任何事物)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)