S.A.Norton Stanley S.A.Norton Stanley - 3 months ago 91
Android Question

Programmatically set TextInputLayout Hint Text Color and Floating Label Color

I use a TextInputLayout, I would want to programmatically set the hint text color and the floating label color if the input field is mandatory. Before moving to TextInputLayout I used to set the hint text color programmatically using the following

textField.setHintTextColor(Color.RED);


Can someone guide me on how to set the hint text color and the floating label color programmatically for a TextInputLayout.

In the screenshot attached i would want the hint text Address 1 to be in red when not focused and the on focus the floating label Address 1 should be in red.

enter image description here

Answer

I was able to get the FloatingLabel in red using the following

textInputLayout.setErrorEnabled(true);
textInputLayout.setError(" ");

enter image description here

Comments