2

screenshot containing two input fields with red hint text

I want to change the hint color to white and keep the color for the error messages red. I have tried all of the possible options but each time the hint color was changed to the color of the error message.

This is the code snippet I used for the style of error messages:

<style name="error_appearance" parent="TextAppearance.Design.Error">
    <item name="android:textColor">@color/error_color</item>
    <item name="android:textSize">@dimen/text_size_medium</item>
</style>
Auspex
  • 2,175
  • 15
  • 35
Rohan Patel
  • 1,758
  • 2
  • 21
  • 38
  • I solve it by setting the backgroundTintList (the underline, officially called Activation indicator) to red and make a TextView holding the error message. Which means I totally give up using the input Layout.error method – Mia Jul 22 '22 at 01:44

1 Answers1

0

This article explains how to style TextInputLayout in the way that you need.

TLDR

Hint color could be set via android:textColorHint parameter of TextInputLayout. This parameter also changes the label default color (label focused color could also be changed in other ways)

Such parameters as app:hintTextAppearance, app:helperTextTextAppearance and app:errorTextAppearance together with all the necessary text parameters of styles.xml should be used to customize labels, helpers and errors in TextInputLayout. The parent of the text appearance style should be TextAppearance.AppCompat or some of its children.

Also, please keep in mind the following: app:hintTextAppearance affects the focused label color and label size in any state; when an error is shown, the bottom/border line will have the color indicated in the android:textColor parameter of errorTextAppearance. This color will be changed to the default once the error is removed.

javdromero
  • 1,850
  • 2
  • 11
  • 19