I changed focused color with reflection. Here's the snippet it may help someone.
private void setUpperHintColor(int color) {
try {
Field field = textInputLayout.getClass().getDeclaredField("mFocusedTextColor");
field.setAccessible(true);
int[][] states = new int[][]{
new int[]{}
};
int[] colors = new int[]{
color
};
ColorStateList myList = new ColorStateList(states, colors);
field.set(textInputLayout, myList);
Method method = textInputLayout.getClass().getDeclaredMethod("updateLabelState", boolean.class);
method.setAccessible(true);
method.invoke(textInputLayout, true);
} catch (Exception e) {
e.printStackTrace();
}
}
EDIT 2018-08-01:
If you are using design library v28.0.0 and later, fields had changed from mDefaultTextColor
to defaultHintTextColor
and from mFocusedTextColor
to focusedTextColor
.
Check decompiled class for other fields.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…