Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何设置TextAppearanceSpan的TextColor?_Android - Fatal编程技术网

Android 如何设置TextAppearanceSpan的TextColor?

Android 如何设置TextAppearanceSpan的TextColor?,android,Android,我目前可以创建中等大小的文本外观span,但如何将文本颜色设置为指定的RBG颜色(例如#c71585) 我看到有一个构造函数 public TextAppearanceSpan(Context context, int appearance, int colorList) { 但是什么是colorList的int?这方面有什么例子吗 谢谢。根据文件: 公共文本外观span(上下文、int外观、int颜色列表) 使用指定的文本外观 资源来确定文

我目前可以创建中等大小的文本外观span,但如何将文本颜色设置为指定的RBG颜色(例如#c71585)

我看到有一个构造函数

public TextAppearanceSpan(Context context, int appearance,
                          int colorList) {
但是什么是colorList的int?这方面有什么例子吗

谢谢。

根据文件:

公共文本外观span(上下文、int外观、int颜色列表)

使用指定的文本外观 资源来确定文本 外观和指定的文本 颜色资源来确定颜色。 外观应该是,比如说,,
android.R.style.TextAppearance\u Small
, 颜色列表应该是,例如 例子,
android.R.styleable.Theme\u textColorDim


为什么不使用不带颜色列表的
文本外观span
,与?

sry一起使用呢?我不能添加注释,上面的说法并不完全正确。。。 通过以下方式访问颜色:

新的前景颜色span(R.color.color\u name,…)

非R.颜色(如上所述)

colors.xml的方案

< color name="bright_green">#44f014< /color>
#44f014

< color name="bright_green">#44f014< /color>

玩得开心

谢谢。我读过。但是,我如何将我的颜色(比如说#c71585)放到android.R.styleable.Theme(主题)textColorDim?我如何将TextAppearanceSpan与ForegroundColorSpan结合使用。我厌倦了spannableStrBuilder.setSpan(文本外观Span,开始-结束);spannableStrBuilder.setSpan(前地面颜色span,开始-结束);我只看到颜色变了。嗯,让我试着给你回电话。我想我的假设可能是错误的,我想我错了。我现在看到了颜色,如果我这样做=newforegroundcolorspan(color.rgb(0,80,0));但如果我使用新的ForegroundColorSpan(R.colors.mycolor)并输入#ffffff0080i解决了它,它就不会起作用。我需要做一个新的ForegroundColorSpan(context.getResources().getColor(R.color.mycolor))为这个错误的警报感到抱歉