Search code examples
androidmaterial-designandroid-textinputlayoutmaterial-components-androidmaterial-components

Resource linking failed when setting app:textColorHint for TextInputLayout of Material Design


I am creating a style for my TextInputLayout like this:

    <style name="AppTheme.TextInputLayout.FilledBox" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
        <item name="android:textColorHint">@color/white</item>
        <item name="textColorHint">@color/white</item> //This line is not getting recognized. 
    </style>

According to the documentation,

android:textColorHint is hint color.

app:hintTextColor is collapsed (floating) hint color.

The issue is happening with styles only. If I set the app:hintTextColor directly to the TextInputLayout, everything is working fine.

I am using the material design:

    implementation 'com.google.android.material:material:1.2.0-alpha06'

I tested it on the sable version 1.1.0 as well. Still, the same issue is happening.


Solution

  • In your style change the item:

    <item name="textColorHint">@color/white</item>
    

    to

    <item name="hintTextColor">@color/white</item>
    

    Something like:

    <style name="MyFilledBox" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">
        <item name="hintTextColor">@color/...</item>
        <item name="android:textColorHint">@color/....</item>
    </style>