繁体   English   中英

如何更改EidtText错误消息的默认背景色

[英]how to change the default background color of EidtText error message

我想将错误消息的背景颜色更改为白色,将文本颜色更改为红色。 我可以使用html格式的文本更改文本颜色。 由于它不支持CSS样式,因此我无法更改错误消息的背景颜色。

图片供参考

我认为您不能使用默认弹出窗口更改背景,而必须创建自己的弹出窗口。

但是更好的解决方案可能是使用TextInputLayout包装您的EditText,然后在TextInputLayout上设置错误。

<android.support.design.widget.TextInputLayout
    android:id="@+id/textInputLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:id="@+id/edittext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Hint"/>

</android.support.design.widget.TextInputLayout>

然后使用

mTextInputLayout.setError("your error string");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM