string.xml

假如遇到需求,一段文字要有不同颜色,文字还要配置在string.xml中

<string name="html_text" formatted="false">
    <![CDATA[
    <font color='#28b5f5'>Hello</font> world.
    ]]>
</string>

TextView tv = (TextView) findViewById(R.id.tv_txt);
tv.setText(Html.fromHtml(getString(R.string.html_text)));