Question Detail

How to Change tint color of EditText programmatically?

3 years ago Views 2016 Visit Post Reply

 I am trying to change the tinting color of an EditText View programmatically during runtime. Basically, i want to change what you would usually apply ?attr/colorControl as like in the Normal background drawable.

Changing the background tint does not correctly apply by just setting a new ColorsStateList with one color:

editText.setBackgroundTintList( ColorStateList.valueOf( color ) );

For one the result is applied to all EditText although the tint list is applied and internally mutates the drawable. Also, the alpha as specified in the default background 1 is visible at the beginning.

Here is the outcome of setting the tint color on just the first EditText:

outcome of setting the tint color on just the first EditText

So my question would be: How can I properly apply the tint programmatically to an  EditText?

Thread Reply


- 3 years ago