我需要帮助显示从下一个字符串资源到 TextView 的颜色
<string name="colored">
<b>Something working perfectly</b>
<font color="#F38">Something that doesn't work</font>
</string>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/colored"
/>
最佳答案
您必须以编程方式设置它,如下所示:
((TextView)findViewById(R.id.yourTextViewId)).setText(Html.fromHtml(getResources().getString(R.string. colored)));
XML:
<TextView android:id="@+id/yourTextViewId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
字符串.xml:
<string name="colored"><![CDATA[
<b>Something working perfectly</b>
<font color="#F38">Something that doesn't work</font>
]]></string>
关于android - 带有字体标签的字符串资源不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22043716/