如何知道Android中TextInputLayout错误的颜色是什么?

问题描述

我在应用程序中使用了几个Textinputlayouts。我怎么知道什么是色错误

enter image description here

解决方法

默认错误颜色基于 colorError 属性。
浅色主题中的current value是:

<color name="design_default_color_error">#B00020</color>

如果要在其他属性中使用它,则可以复制此值,也可以使用 ?attr/colorError 。示例:

<item name="strokeColor">?attr/colorError</item>

如果要通过编程方式获取此值,可以使用:

MaterialColors.getColor(fab,R.attr.colorError)
,

布局错误的默认颜色是红色。您可以根据需要进行更改。您只需要在style.xml中添加行

<style name="TextInputLayoutError" parent="@android:style/TextAppearance">
    <item name="android:textColor">your color</item>
    <item name="android:textSize">12sp</item>
</style>

在TextInputLayout标记中使用以下标记

app:errorTextAppearance="@style/TextInputLayoutError">