我的意思是:
<string name="error" color="#9a1d1d">Error!</string>
最佳答案
根据 rekire 的建议,无法按照您的方式设置颜色。
您可以使用rekire建议的方法。
在您的 xml 中,您可以将 TextView 的颜色指定为
android:textColor="#0EFFFF"
您还可以通过编程方式设置文本颜色
TextView tv= (TextView)findviewById(R.id.textView1);
tv.setTextColor(Color.RED);
要在 textview 中设置特定单词的颜色,您可以使用 spannable string
TextView tv= (TextView)findviewById(R.id.textView1);
tv.setText("");
String s="Hello World";
SpannableString ss= new SpannableString(s);
ss.setSpan(new ForegroundColorSpan(Color.GREEN), 0, 5, 0);
tv.setText(ss);
关于android - 是否可以直接在string.xml中设置字符串的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15997186/