Search code examples
androidandroid-textinputlayout

How to know what is color of TextInputLayout error in Android?


I am using several Textinputlayouts in my app. How may I know what is color lf its error? enter image description here


Solution

  • The default error color is based on the colorError attribute.
    The current value in a light theme is:

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

    If you want to use it in another attribute you can copy this value or you can use ?attr/colorError. Example:

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

    If you want to get programmatically this value you can use:

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