【发布时间】:2015-09-27 19:14:41
【问题描述】:
我有以下字符串:
<string name="welcome.location.services">Please <font color='green'>ALLOW</font> Passenger to access your location in order to track your trips.</string>
如果我这样保留它,它将使用默认绿色显示为 ALLOW。但我需要一种不同的颜色。我怎样才能改变它? 试过了:
<font color='#ff00ff'>ALLOW</font>
但是这个词不会有这样的颜色。 我想在 strings.xml 中执行此操作,因为每种语言都有更多文件,并且单词长度和起始索引不同,使得可跨字符串难以使用
PS:我尝试使用 HTML.fromHTML 但仍然没有运气:
((TextView)dialog.findViewById(R.id.header4)).setText(Html.fromHtml(context.getString(R.string.welcome_location_services)));
字符串在哪里:
<string name="welcome.location.services">Please <font color='#ffff00d3'>ALLOW</font> Passenger to access your location in order to track your trips.</string>
【问题讨论】:
-
你在用
Html.fromHtml吗? -
@Blackbelt,我是从布局文件中设置的。不是以编程方式
标签: android string text colors textcolor