doe
doe

Reputation: 981

How to change hint text color of edittext when TextInputLayout is used

I have a screen with edittexts. When these edittexts are disabled, I need the hint color to be in one color
enter image description here

When these are enabled, I need the hint to be in a different color like this

enter image description here

This works fine when I tried like this

     editText.setHintTextColor(color);

The problem is , I have to use a TextInputlayout to show the floating hint. So, When I add the EditText inside TextInputLayout this code doesn't work at all. I tried many things with TextInputLayout as shown here. But nothing works. All I need is the hint text color (Not floating hint text) of the EditText should be in one color when enabled , and in different color when disabled, when used inside a TextInputLayout. Please help!

Note: My question is not a duplicate of this question. There , it is mentioned about the floating hint text of the TextInputLayout when it is focused What I am talking about the normal hint text when the edit text is not focused and also when it is empty.

Upvotes: 1

Views: 659

Answers (1)

Mbuodile Obiosio
Mbuodile Obiosio

Reputation: 1543

Add these to your App theme

<item name="colorControlNormal">@color/color</item>
<item name="colorControlActivated">@color/color</item>
<item name="colorControlHighlight">@color/color</item>
<item name="android:textColorHighlight">@color/color</item>

Upvotes: 0

Related Questions