I find this list of material design color and I want to get random color from it. I am new in android development and don't fully understand how android resources works.
I know that I can get the custom color by R.color.my_color
from res/values/colors.xml
but I want to separate my app custom colors from material design colors.
What I'm trying to do:
- Import the xml file from the link to my project under
res
folder (ex.res/values/android_material_design_colours.xml
) Get all colors from the file
int[] allColors =
(missing part)Get the random color by using
Random
classint randomColor = allColors[new Random().nextInt(allColors.length)];
Is this possible or are there any better way? Please Help.