What's the difference between ?android:attr/
and ?attr/
in an Android layout XML file?
Which one should we use in different situations?
From Difference between “?attr/” and “?android:attr/” in Android:
1. ?attr/
Defines and refers to the value of an attribute which you have defined on your own in your application.
2. ?android:attr/
It refers to the values of an attribute which are already available in Android built-in. More specifically, the
?
implies an extra level of indirection. Think of it as de-referencing an attribute to fetch the resource it points to rather than referring to the attribute itself.
?android:attr/
and ?android:
? For example, there are colors ?android:attr/textColorPrimary
and ?android:textColorPrimary
. Both seem to work in the same way, but I didn't dig into the themes and code to check for differences. Official documentation on these seem to be quite scarce.
Jun 7, 2019 at 9:16
From Difference between “?attr/” and “?android:attr/” in Android:
?attr/
- Defines and refers to the value of an attribute which you have defined on your own in your application.
?android:attr/
- Refers to the values of an attribute which are already available in Android built-in.