tags:

views:

61

answers:

2

In the string.xml file i use the following tag

<color name="mycolor1">#F5DC49</color>

if i use

 textview1.setTextColor(Color.CYAN);

it works, But

 textview1.setTextColor(R.color.mycolor1);

This is not working

how to use the color tag in android.

A: 

What you are doing is correct, but Android uses 4 bytes for color, not 3. The first byte is the alpha. You are giving it a color where the alpha value is 0, thus making your color completely transparent.

Change your color definition to this:

<color name="mycolor1">#FFF5DC49</color>

And you should find that everything starts working like you would expect it to.

mbaird
You can set the alpha this way true but you don't have to. You can use following formats #AARRGGBB, #RRGGBB and #RGB (the short version) like #000 for black for example.
Octavian Damiean