Since it is not easy to customize the color of the error in a TextInputLayout, I decided to change my error colour to match the one used by default by TextInputLayout.
In the design guidelines I could not find the definition of the default colour.
Do you know where I can find it?
TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.
The primary use of a TextInputLayout is to act as a wrapper for EditText(or its descendant) and enable floating hint animations. Rule of Thumb : TextInputLayout should wrap TextInputEditText instead of the normal EditText.
The only solution I found was to check the code of TextInputLayout. I found that the style is
<style name="TextAppearance.Design.Error" parent="TextAppearance.AppCompat.Caption">
<item name="android:textColor">@color/design_textinput_error_color</item>
</style>
where
<color name="design_textinput_error_color">#FFDD2C00</color>
but it seems this is not documented so it can change
Update in 2020.
TextInputLayout error color can be acquired via:
ContextCompat.getColor(this, com.google.android.material.R.color.design_error)
But it is marked private and can be changed. Approximately color value is:
<color name="color_text_input_error_color">#E87850</color>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With