我想更改value/string.xml
中不在Layout
中的数组中的文本颜色,但也不是所有文本,而是部分内容
例如:
<string-array name="list">'
// like Cafe in example i want it red and bold but not other text.`
<item>Welcome to Cafe</item>'
// and shop to be purple
<item>The new online Shop!</item>'
//in java i would set
welcome.setText(*and one of the array item*);
答案 0 :(得分:1)
您可以在string.xml中编写html,让它们看上去很棒。
// like Cafe in example i want it red and bold but not other text.`
<item>Welcome to <b>Cafe</b></item>'
// and shop to be purple
<item>The new online <span style="...">Shop!</span></item>'
// FOR EXAMPLE ONLY, use XML CDATA in the link provided.
textView.setText(Html.fromHtml(YOUR_STRING_FROM_XML), TextView.BufferType.SPANNABLE);