相关疑难解决方法(0)

在Android中设置TextView span的颜色

是否可以在TextView中设置文本范围的颜色?

我想做一些类似于Twitter应用程序的东西,其中一部分文本是蓝色的.见下图:

替代文字

formatting android text textview

188
推荐指数
12
解决办法
15万
查看次数

如何使用我的values/colors.xml文件中定义的颜色更改TextView的背景颜色?

我正在使用Eclipse开发一个Android项目.我想使用我在res/values/colors.xml中定义的颜色之一来更改TextView的背景颜色.使用R.color.color_name可以获得这些颜色.

我的问题是,这根本行不通.更改为我定义的颜色之一总是将TextView的背景设置为其默认颜色,在本例中为黑色.如果我使用Java的内置颜色之一,它可以正常工作.我认为这是一个颜色定义问题,涉及我在XML中实际定义颜色的方式,但我不确定.

// This works:
weight1.setBackgroundColor(Color.BLACK);

// This does not work:
weight2.setBackgroundColor(R.color.darkgrey);

// Color Definition: (this is in a separate xml file, not in my Java code)
<color name = "darkgrey">#A9A9A9</color>
Run Code Online (Sandbox Code Playgroud)

android textview

6
推荐指数
2
解决办法
2万
查看次数

标签 统计

android ×2

textview ×2

formatting ×1

text ×1