[FIXED] How to get color by id from another android xml file


I’m new in android development and I facing with the following problem:
I have .xml vector images in drawable and I want to create several color presets for them.

As I understand it, to achieve this purpose i need to create sets of colors for presets in colors.xml and then get a certain set i need.

The question is how can I get, for example,
<color name="input_lines">#ffffff</color>
by "input_lines" name from image.xml file?

I tried to use *"@android:color/input_lines", "@colors/input_lines" and "@android:R.color.input_lines"* but it doesn’t work


it’s not "@colors/input_lines"

if you are talking about referring to a color that is from colors.xml into another .xml file , then it’s "@color/input_lines".

but if you are referring to that color from activity then it’s

int color1 = getResources().getColor(R.color.input_lines);

Answered By – abdo Salm

Answer Checked By – Cary Denson (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published