0

An app uses the following MyThemeStyle for its theme:

<style name="MyThemeStyle" parent="@style/Theme.MaterialComponents">
    <item name="hintTextAppearance">@style/HintText</item>
    <item name="hintTextColor">@color/red</item>
</style>
<style name="HintText" parent="TextAppearance.AppCompat">
    <item name="android:textColor">@color/red</item>
</style>

In AndroidManifest:

<application
    android:theme="@style/MyThemeStyle">

This works for EditText, but has no effect on com.google.android.material.textfield.TextInputLayout.

Could anyone shed some light on this?

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
Hong
  • 17,643
  • 21
  • 81
  • 142

1 Answers1

1

You can use:

<style name="AppTheme" parent="Theme.MaterialComponents.Light">
  <item name="textInputStyle">@style/TextInput</item>
</style>

<style name="TextInput" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
   <item name="hintTextAppearance">@style/....</item>
   <!-- The color of the label when it is collapsed and the text field is active -->
   <item name="hintTextColor">?attr/colorPrimary</item>

   <!-- The color of the label in all other text field states (such as resting and disabled) -->
   <item name="android:textColorHint">@color/mtrl_indicator_text_color</item>
</style>
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • 1
    Thank you. I would never be able to figure out it with my current knowledge of MDC. – Hong Dec 09 '20 at 20:52