0

When I attemp to use some resource in activity_main.xml like that

    android:minHeight="?android:actionBarSize"
    android:background="?attr/colorPrimary"

I found some thing i can't understand.I know the "android:" means system level attribute when an XML parser reads the document, "attr" means the attribute in my theme(right?), but why some attribute should add the package name "android:",though there is a same attribute? such as i can define attribute in my styles.xml like this

    <item name="colorPrimaryDark">@color/purple</item>

but i also can define attribute like

    <item name="android:colorPrimaryDark">@color/purple</item>

My English is very bad,so mybe i haven't explain what i want to figure out.

Kermit
  • 3
  • 4
  • `"android:" means system level attribute` no it does not - http://stackoverflow.com/questions/1181888/what-does-xmlns-in-xml-mean – Simon Aug 09 '15 at 06:06

1 Answers1

0

(from this answer )

Prefixing the ID with a question mark indicates that you want to access a style attribute that's defined in a style theme, rather than hard-coding the attribute, as explained in Referencing Style Attributes.

More specifically, the ? implies an extra level of indirection. Think of it as dereferencing a theme attribute to fetch the resource it points to rather than referring to the attribute itself. You see this with ?android:attr/foo

Community
  • 1
  • 1
Noman Rafique
  • 3,735
  • 26
  • 29