美文网首页
Android setTextColor 不生效

Android setTextColor 不生效

作者: _10_01_ | 来源:发表于2019-03-08 14:46 被阅读0次

# Android中设置TextView的颜色setTextColor

Android 在代码中使用 setTextColor 修改文本颜色,
但使用button.setTextColor(ContextCompat.getColor(ctx, R.color.selector_button)),并不能符合预期的让 Button使用Selector;
需要使用 Button.setTextColor(ctx.getResources().getColorStateList(R.color.selector_button))才会让Selector生效,不然Button将会固定为一个颜色。

相关文章

网友评论

      本文标题:Android setTextColor 不生效

      本文链接:https://www.haomeiwen.com/subject/biyrpqtx.html