Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between “?android:attr/” and “?attr/” in an android layout xml file?

Tags:

What's the difference between ?android:attr/ and ?attr/ in an android layout xml file? Which one should we use in different situations?

like image 903
zzh0838 Avatar asked Apr 15 '16 08:04

zzh0838


People also ask

What is attr in XML Android?

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.

What does the @android mean in Android Studio?

They are using the same name which means they represent the same resource.

What is the name of the file which is used to declare custom attributes?

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 Answers

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.

like image 91
User_1191 Avatar answered Oct 26 '22 21:10

User_1191