Search code examples
androidandroid-design-libraryandroid-textinputlayout

how to change color of TextinputLayout's label and edittext underline android


I am using android design library's TextinputLayout. But couldn't customize the hint color, label color and the underline color of EditText inside TextinputLayout. Please help.


Solution

  • Change bottom line color:

    From this answer

     <item name="colorControlNormal">#c5c5c5</item>
     <item name="colorControlActivated">@color/accent</item>
     <item name="colorControlHighlight">@color/accent</item>
    

    Change hint color when it is floating

    <style name="MyHintStyle" parent="@android:style/TextAppearance">
        <item name="android:textColor">@color/main_color</item>
    </style>
    

    and use it like this:

    <android.support.design.widget.TextInputLayout
        ...
        app:hintTextAppearance="@style/MyHintStyle">
    

    Change hint color when it is not a floating label:

    <android.support.design.widget.TextInputLayout
        ...
        app:hintTextAppearance="@style/MyHintStyle"
        android:textColorHint="#c1c2c4">
    

    Thanks to @AlbAtNf