以编程方式设置editText突出显示颜色
问题描述:
如果语法焦点集合,我想更改editTexts行的颜色。以编程方式设置editText突出显示颜色
我已经尝试过使用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);
我能够改变线的正常颜色,但重点始终是在应用editTexts的默认颜色。
与此默认为灰色,重点是应用程序默认可以说,绿色的,但我希望有一个可以说红色在提出线程集中
答案是基于XML的,我要动态地设置它,也只有高亮/对焦颜色不同,普通颜色保持灰色
答
创建自定义EditText
并将this.setBackgroundTintList(ColorStateList.valueOf(color));
添加到构造函数中。
[改变EditText底线颜色与appcompat v7]可能的重复(https://stackoverflow.com/questions/26574328/changing-edittext-bottom-line-color-with-appcompat-v7) – noongiya95