Android 5.1上的setTextColor

Android 5.1上的setTextColor,android,text,colors,textview,android-5.1.1-lollipop,Android,Text,Colors,Textview,Android 5.1.1 Lollipop,为什么只有在Android 5.1或更高版本上setTextColor方法不起作用 TextView TextView32 = (TextView) findViewById(R.id.textView32); TextView32.setText(String.valueOf(LikesNumber2)); SendLikes2.setBackgroundResource(R.drawable.likeyes); TextView32.setTextColor(Color.parseColor

为什么只有在Android 5.1或更高版本上
setTextColor
方法不起作用

TextView TextView32 = (TextView) findViewById(R.id.textView32);
TextView32.setText(String.valueOf(LikesNumber2));
SendLikes2.setBackgroundResource(R.drawable.likeyes);
TextView32.setTextColor(Color.parseColor("#ffffff"));
奇怪,但在安卓4.4及以上版本的30部手机上,文本颜色会发生变化。哪里有错误

XML:


您可以使用

TextViewObj.setTextColor(getResources().getColor(R.color.Color_Name));
TextViewObj.setTextColor(getResources().getColor(R.color.Color_Name));
或者使用ContextCompat

TextViewObj.setTextColor(ContextCompat.getColor(context,R.color.Color_Name));

希望这有帮助。

您正在尝试

 TextView32.setTextColor(Color.parseColor("#ffffff"));
它是白色的。您的背景色不是白色吗

尝试将背景色设置为灰色(#808080)或其他颜色,并将颜色设置为


这条线应该很好用。在4.4、5.1、6.0中测试,奇怪。android 5.1.1Use
ContextCompat.getColor()
,请参阅。感谢您的帮助,但我认为问题出在ImageView中。它可以强制文本(我不知道我怎么用英语说——比如“你看不到文本,因为图像视图在它们上面”)。所以问题并没有解决
TextViewObj.setTextColor(getResources().getColor(R.color.Color_Name));
textView.setTextColor(Color.parseColor("#DD1515"));