When I look at misc. Android tutorials and examples when it comes to specifying colors I very often see constants like @color/red
or @color/black
etc. being used. For some strange reason that NEVER works for me! I always need to specify colors using the "#RGB", #ARGB, ..., #AARRGGBB notation.
As soon, as I try to use any of those mnemonic constants like e.g. "@color/red" I am getting error messages like these:
[...] C:\Users\mmo\Test\res\drawable\edit_text.xml:5: error: Error: No resource found that matches the given name (at 'drawable' with value '@color/orange').
[...] C:\Users\mmo\Test\res\drawable\myDrawable.xml:3: error: Error: No resource found that matches the given name (at 'drawable' with value '@color/black').
[...] C:\Users\mmo\Test\res\drawable\myDrawable.xml:4: error: Error: No resource found that matches the given name (at 'drawable' with value '@color/black').
[...] C:\Users\mmo\Test\res\drawable\myDrawable.xml:5: error: Error: No resource found that matches the given name (at 'drawable' with value '@color/green').
[...] C:\Users\mmo\Test\res\drawable\myDrawable.xml:6: error: Error: No resource found that matches the given name (at 'drawable' with value '@color/black').
Why is that so? Why can't I use these predefined constants? Do I need to prefix them with some package name (I tried @android:color/red
but that only caused a different error)?
Do I need to specify these colors myself? If so: how and where? Any ideas or suggestions?
Michael