I made an array of items with colors in the colors.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<array name="rectangle_colors">
<item>
<color>#77aa3535</color>
</item>
<item>
<color>#44cc1818</color>
</item>
<item>
<color>#ff1068</color>
</item>
<item>
<color>#6090cc</color>
</item>
<item>
<color>#6040aa</color>
</item>
</array>
</resources>
I want to access these colors both in Java and in other XML files. I found plenty of help on how to access them in Java, but nothing for accessing them in XML beyond the documentation here. I can't figure out how to use the pattern they provide:
@[package:]array.array_name
I tried this:
android:background="@[com.example.jason.miniproject].array.rectangle_colors[0]"
but it doesn't work.
Is there any way for me to browse all of my XML resource values in Android Studio other than the auto-complete feature that pops up when I start typing in the right spot?
Also, am I going about this wrong way? I have a bunch of views and I want those views to start off with different background colors. I'd like to get those colors from an XML file. Then I want to change those colors in Java as the user interacts with the app. The new colors will be variations of the initial colors, so I'll want to iterate over the initial colors in Java. Is my approach to storing those colors a good idea?