What's the difference between ?android:attr/
and ?attr/
in an android layout xml file? Which one should we use in different situations?
The Attr interface represents an attribute in an Element object. Typically the allowable values for the attribute are defined in a schema associated with the document.
They are using the same name which means they represent the same resource.
You can take a look at it here (attrs. xml). You can define attributes in the top <resources> element or inside of a <declare-styleable> element.
1. ?attr/
Defines and refers to the value of an attribute which you have defined on your own in your application.
2. ?android:attr/
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With