How to change the color of an EditText line / field to TextInputLayout (when calling setError)?

When I call setErrorin TextInputLayoutfrom the new Android design support library , the line color does not change. But the error is successfully displayed with the correct color.

This is the code I'm using:

textInputLayout.setError("Error Message");

In the Material Specification for text fields , when there is an error, the color of the line / field should be red.

How to set the color of the line?

If this can be done as a side effect of the call setError, that would be great.

+4
source share
1 answer

You can add

editText.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);

After

textInputLayout.setError("Error Message");.

+4
source

All Articles