我在string
文件中创建了string.xml
,并希望将句子中兴奋,冒险的color
更改为yellow
。我试图添加<font color="yellow">Excitement, Adventourous</font>
,但这无济于事。
<string name="screen114_3">EMOTION Driver5- UNCERTAINTY/VARIETY (Surprise, Diversity, Challenge,<font color="yellow">Excitement, Adventurous</font>, Wild)
</string>
答案 0 :(得分:0)
尝试一下:
String text = "EMOTION Driver5- UNCERTAINTY/VARIETY (Surprise, Diversity, Challenge,<font color="yellow">Excitement, Adventurous</font>"
mTextView.setText(Html.fromHtml(text));
答案 1 :(得分:0)
使用CDATA
,试试看
<string name="screen114_3"><![CDATA[EMOTION Driver5- UNCERTAINTY/VARIETY (Surprise, Diversity, Challenge,<font color="yellow">Excitement, Adventurous</font>, Wild]]></string>
然后添加
String colouredString = getResources().getString(R.string.screen114_3);
textview.setText(Html.fromHtml(colouredString));