标签:
通过代码setTextColor时、如果color是一个资源文件 会set失败 没有效果
遇到这样的情况有两种解决办法、亲测过、两种都是有效的
通过在方法上面添加注解解决问题
代码如下
@SuppressLint("ResourceAsColor")
通过Context 获取getColorStateList 来解决问题
代码如下
int color = getContext() .getResources() .getColorStateList(R.color.reservation_text); textView.setTextColor(color);
上面的两种方式都可以解决这个问题哈、希望对一些哥们有帮助
Android setTextColor无效_安卓setTextColor()的参数设置方式
标签:
原文地址:http://www.cnblogs.com/zhujiabin/p/4617881.html