textColorHint is ignored as hint text color is always colorAccent

Lars Nielsen

I am trying to create a text field layout similar to material design - error user input, but I am facing an issue with the hint color. The Material Design guidance states the hint color for a light theme should be

Hint and helper text: #000000 with 38% opacity

which made me add <item name="android:textColorHint">@color/hint_color</item> to my AppTheme and <color name="hint_color">#61000000</color> to my colors.xml.

However, the hint color always the same as my <item name="colorAccent">@color/accent</item> (part of AppTheme) which is currently set to light blue.

So how can I fix this? I have tried to set the hint color directly on the TextInputLayout and AppCompatEditText but no luck.

Thanks,

Lars

Lars Nielsen

Found the solution:

  1. Make sure xmlns:app="http://schemas.android.com/apk/res-auto" is defined in your layout
  2. Define the following attribute on the TextInputLayout app:hintTextAppearance="@style/TextAppearence.TextInputLayout.Light.Hint"
  3. Define the style in your styles.xml

    <style name="TextAppearence.TextInputLayout.Light.Hint" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/textinput_hint_light_color</item>
    <item name="android:textSize">16sp</item></style>
    
  4. Finally define the color <color name="textinput_hint_light_color">#61000000</color> in your colors.xml (38% of 255 converted to hex is 61)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Android 4.3+, android:textColorHint doesn't work, hint color is always white

From Dev

Android 4.3+, android:textColorHint doesn't work, hint color is always white

From Dev

text color for hint in EditText not working

From Dev

text color for hint in EditText not working

From Dev

Is GREP_OPTIONS= --color=always ignored?

From Dev

Set text color and hint text color to the text in SearchView

From Dev

Changing action bar searchview hint text color

From Dev

How to change the hint's text color of PlaceAutocompleteFragment?

From Dev

Programmatically set TextInputLayout Hint Text Color and Floating Label Color

From Dev

Change text color of search hint in actionbar using support library

From Dev

UIBarButtonItem Title Text is Always Global Tint Color

From Dev

Android Button Text Color Always Pink

From Dev

showAsAction = "always" is ignored in Toolbar

From Dev

Expression is always true Resharper Hint

From Dev

Hint and jump to text box

From Dev

Moving hint text in textview

From Dev

Android: Edit text hint

From Dev

Android webview hint text

From Dev

Underline EditText Hint Text

From Dev

Android webview hint text

From Dev

Android: Edit text hint

From Dev

CSS color attribute ignored

From Dev

Change color of hint EditText - Android

From Dev

No resource found that matches the given name (at 'colorAccent' with value '@color/Accent')

From Dev

What should be the color of the Ripple, colorPrimary or colorAccent? (Material Design)

From Dev

Indeterminate circle progress bar on android is white, despite colorAccent color

From Dev

FloatingActionButton Rendering: Color value '?attr/colorAccent' must start with #

From Dev

Using appcompat's ?colorAccent in a color selector doesn't seem to work

From Dev

Optional capture always ignored in favor of *

Related Related

  1. 1

    Android 4.3+, android:textColorHint doesn't work, hint color is always white

  2. 2

    Android 4.3+, android:textColorHint doesn't work, hint color is always white

  3. 3

    text color for hint in EditText not working

  4. 4

    text color for hint in EditText not working

  5. 5

    Is GREP_OPTIONS= --color=always ignored?

  6. 6

    Set text color and hint text color to the text in SearchView

  7. 7

    Changing action bar searchview hint text color

  8. 8

    How to change the hint's text color of PlaceAutocompleteFragment?

  9. 9

    Programmatically set TextInputLayout Hint Text Color and Floating Label Color

  10. 10

    Change text color of search hint in actionbar using support library

  11. 11

    UIBarButtonItem Title Text is Always Global Tint Color

  12. 12

    Android Button Text Color Always Pink

  13. 13

    showAsAction = "always" is ignored in Toolbar

  14. 14

    Expression is always true Resharper Hint

  15. 15

    Hint and jump to text box

  16. 16

    Moving hint text in textview

  17. 17

    Android: Edit text hint

  18. 18

    Android webview hint text

  19. 19

    Underline EditText Hint Text

  20. 20

    Android webview hint text

  21. 21

    Android: Edit text hint

  22. 22

    CSS color attribute ignored

  23. 23

    Change color of hint EditText - Android

  24. 24

    No resource found that matches the given name (at 'colorAccent' with value '@color/Accent')

  25. 25

    What should be the color of the Ripple, colorPrimary or colorAccent? (Material Design)

  26. 26

    Indeterminate circle progress bar on android is white, despite colorAccent color

  27. 27

    FloatingActionButton Rendering: Color value '?attr/colorAccent' must start with #

  28. 28

    Using appcompat's ?colorAccent in a color selector doesn't seem to work

  29. 29

    Optional capture always ignored in favor of *

HotTag

Archive