i've wondered time , time again if there way define colors in colors.xml
referencing color has been defined. well, tried , indeed, appears though can reference other colors using @color/xxx.
for example one's colors.xml like:
<?xml version="1.0" encoding="utf-8"?> <resources> … <color name="primary_blue">#205081</color> <color name="action_bar_text">@color/primary_blue</color> … </resources>
but don't want others use primary_blue
definition directly -- doesn't make sense make blue without context. best solution i've come prefix 'direct' colors primary_blue
, comment shouldn't used directly.
is there way prevent use of these direct colors, while still allowing colors.xml file reference them? i'm thinking perhaps styles or apklib me out.
as said in android developper site : http://developer.android.com/guide/topics/resources/providing-resources.html
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="highlight">@color/red</color> </resources>
as simple
Comments
Post a Comment