In android developer examples, blogs, etc, I have seen multiple prefixes for the values of style attributes. Can someone please describe when to use what? For example, what is the difference between these 3 cases?
parent="@android:style/TextAppearance" parent="TextAppearance.AppCompat" parent="@style/TextAppearance.AppCompat"
What is the difference between these 2 cases?
<item name="colorControlNormal">@color/white</item> <item name="android:colorControlNormal">@color/white</item>
Without any prefix references the style named on the same file.
@Style references your style.xml project file.
@android:style references defined Android API style.
About colorControlNormal vs android:colorControlNormal is the same explanation. If you use controlColorNormal you are defining the color applied to framework controls in their normal state in you app. If you use android:colorControlNormal you are overwriting the the color default applied to framework controls by the system.
You can think of @ as signaling that a named resource is coming up.
@type/name identifies a resource of type
type (string, color, layout, style etc) with name
name defined in the app is coming up.
@+id/name identifies an id resource called
name that will be created if it doesn’t already exist (whereas @id simply refers to an id that already exists).
@android:type/name means that the named resource is part of the Android platform is coming up (it’s not defined in the app — it’s provided by the device).
For style parents, the @style is optional. You can refer to styles directly by name. It’s redundant because you can’t derive a style from anything other than another style anyway.