Android中给TextView设置颜色无效的问题
2017-07-09 18:09
363 查看
1.场景
在适配器中给某个TextView设置不同的颜色属性时,发现怎么设置也不成功,最后发现是自己的设置方式不对,我之前的写法是mTextView.setTextColor(R.color.***),发现这样写是无效的
2.解决
通过百度,解决方法如下:
1.直接使用Color.parse(String color)
2.通过调用Resources对象的getColor(int color)方法
mTextView.setTextColor(Color.parseColor("#333333"));
记录曾经遇到的坑~~~
在适配器中给某个TextView设置不同的颜色属性时,发现怎么设置也不成功,最后发现是自己的设置方式不对,我之前的写法是mTextView.setTextColor(R.color.***),发现这样写是无效的
2.解决
通过百度,解决方法如下:
1.直接使用Color.parse(String color)
2.通过调用Resources对象的getColor(int color)方法
mTextView.setTextColor(Color.parseColor("#333333"));
mTextView.setTextColor(this.getResources().getColor(R.color.colorAccent));
记录曾经遇到的坑~~~
相关文章推荐
- android TextView 设置Marquee无效问题,最简便的设置
- android中用Spannable在TextView中设置超链接、颜色、字体
- android中用Spannable在TextView中设置超链接、颜色、字体
- android TextView、EditText对部分内容设置颜色、字体、超链接、图片、点击事件
- android TextView的字体颜色设置的多种方法
- android:为TextView添加样式——下划线,颜色,设置链接样式及前背景色
- android imageView 和TextVIew 颜色的透明度问题
- Android TextView当中设置超链接、颜色、字体
- Android设置TextView的Selector来控制点击的颜色
- android background设置颜色后就成textview了
- android--设置TextView部分文字的颜色和背景(高亮显示)
- 【工作笔记】android TextView、EditText对部分内容设置颜色、字体、超链接、图片
- Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性
- Android TextView内容设置超链接、颜色、字体
- android--设置TextView部分文字的颜色和背景(高亮显示)
- android 的TextView空间动态设置字体颜色
- Android TextView中文字设置超链接、颜色、字体
- android--设置TextView部分文字的颜色和背景(高亮显示)
- ANDROID TEXTVIEW 设置字体颜色
- Android TextView当中设置超链接、颜色、字体