Tima Tima - 9 months ago 42
Android Question

Android get color as string value

If i defined a color in resources

<color name="someColor">#123456</color>

it's possible to set color by its id, like


Is it also possible to get color string value from colors.xml?

Something like

colorStr = getColor(R.color.someColor);
// -> colorStr = "#123456"

If yes, can anybody give an example?

Thank you


This is your answer


you will get

 colorStr = "#123456"