想要更改错误框的背景颜色而不是文本颜色。我尝试设置 setErrorTextColor、setErrorColor、setBackGroundColor 的方式未定义。请提出一些解决方案。 预先感谢。
您可以使用以下代码更改editText错误块的颜色。
yourEditText.setErrorColor(Color.parseColor("Pass Your Color Code"));
我建议您切换到Material.io TextInputLayout,它不仅提供更流畅的错误处理API,而且还具有更多自定义功能
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
有关 Material.io 版本的 Edittext 附带的所有功能的深入文档,请访问 Material.io 文本字段 - Android