tags:

views:

151

answers:

3

Hi,

I currently able to create a Medium size TextAppearanceSpan, But how can I set the text color to a specified RBG color (say #c71585)?

new TextAppearanceSpan(context, android.R.style.TextAppearance_Medium);

I see there is a constructor for

public TextAppearanceSpan(Context context, int appearance,
                          int colorList) {

But what is the int for colorList? Is there any example for this?

Thank you.

A: 

According to the Docs:

public TextAppearanceSpan (Context context, int appearance, int colorList)

Uses the specified TextAppearance resource to determine the text appearance, and the specified text color resource to determine the color. The appearance should be, for example, android.R.style.TextAppearance_Small, and the colorList should be, for example, android.R.styleable.Theme_textColorDim.

CaseyB
Thank you. I read that. But how can I put my color say #c71585 to android.R.styleable.Theme_textColorDim?
michael
A: 

Why not use a TextAppearanceSpan with no colorList, in conjunction with a ForegroundColorSpan?

Roman Nurik
How can I use TextAppearanceSpan in conjunction with ForegroundColorSpan. I tired spannableStrBuilder.setSpan(TextAppearanceSpan, start end); spannableStrBuilder.setSpan(ForegroundColorSpan, start end);I only see the color is changed.
michael
Hm, let me try and get back to you. I guess my assumption that it would work may have been faulty.
Roman Nurik
I think I am wrong. I see the color now, if I do this= new ForegroundColorSpan(Color.rgb(0, 80, 0));but it won't work if i do new ForegroundColorSpan(R.colors.mycolor) and I put <color name="mycolor">#ffff0080</color>
michael
I have resolved it. I need to do new ForegroundColorSpan(context.getResources().getColor(R.color.mycolor))Sorry for the false alarm
michael
A: 

sry, i can't add a comment, the above statement isn't totally correct... accessing the color via:

new ForegroundColorSpan(R.color.color_name,..)

not R.colors (as above)

scheme of colors.xml

< resources >

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

< /resources >

have fun

cV2