Android: Setting EditText's default hint color from .java

对着背影说爱祢 提交于 2019-12-02 01:33:24

It may be too late but for the sake of others who have the same problem, I solved it by making a method to get default textColorHint.
It returns the color of the hint text for all the states (disabled, focussed, selected...) that specified in the current theme.

int getHintTextColor(Context context) {
    int[] hintTextColor = new int[] { android.R.attr.textColorHint };
    int indexOfAttrTextColorHint = 0;
    TypedArray ta = context.obtainStyledAttributes(hintTextColor);
    int textColor = ta.getColor(indexOfAttrTextColorHint, 0xFF808080);
    ta.recycle();
    return textColor;
}

I hope this helps.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!