TextInputLayout 错误消息大小

2023-12-05

有没有办法强制 TextInputLayout 错误消息占一行?

我试图放置app:errorTextAppearance="@style/error_appearance"在带有 error_appearance 样式的 TextInputLayout 上包含:

<item name="android:maxLines">1</item>
<item name="android:ellipsize">end</item>
<item name="android:inputType">text</item>

它不起作用。然而改变颜色是有效的。我不明白,mErrorView 只是一个 TextView,它应该可以工作。

TextInputLayout error message


您可以通过 id 获取错误 TextView

TextView errorView = textInputLayout.findViewById(R.id.textinput_error);
errorView.setMaxLines(1);
errorView.setSingleLine(true);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

TextInputLayout 错误消息大小 的相关文章

随机推荐