Home > Back-end >  @color/black vs @android:color/black
@color/black vs @android:color/black

Time:06-01

As the title suggests, I noticed there were two options for black color, and that made me wonder, is there any difference between @color/black and @android:color/black when styling texts etc.? Is there a reason why those two exist separately?

CodePudding user response:

@android:color/black - this references to Android framework built-in value, which is unchanged and points on #000000 color. Until Android folks won't make for us any joke in some OS release it is safe and reliable reference to use, in API since the beginning

@color/black - this points on your custom reference declared in your app. You can put in there any color in fact, thus in that way quick re-styling whole app. (btw. it's better to use location-naming e.g. list_separator or fragment_background_default for keeping this possibility) Or you can remove this entrance in colors.xml (most common) and then @color/black becomes "unresolveable" (app won't build)

CodePudding user response:

As far as I know, using the resources under @android: are those integrated by default in the android version the app is installed, so can change if the values are changed in newer android versions.

if you use the normal @color/ you are referencing your color.xml file, and no matter any change in the android version, this will always be the color you assign.

  • Related