I would like to change the editTexts line color grammatically if its focused.
I already tried to use a colorStateList
int[][] states = new int[][]{
new int[]{android.R.attr.state_focused},
new int[]{android.R.attr.state_active },
new int[]{ -android.R.attr.state_enabled},
new int[]{android.R.attr.state_enabled},
};
int[] colors = new int[]{
highlightColor,
defaultColor,
defaultColor,
defaultColor
};
ColorStateList myList = new ColorStateList(states, colors);
editText.setBackgroundTintList(myList);
I am able to change the normal color of line but the focused is always the default color for editTexts in app.
with this the default is grey, focused is default from app lets say green but I want a lets say red in focused
answers in the proposed thread are XML based, I have to set it dynamicly, also ONLY the highlight/focused color is different, the normal color stays grey