Tima Tima - 2 years ago 136
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

Answer Source

This is your answer


you will get

 colorStr = "#123456"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download