What's the difference between @android: and ?android: [duplicate]

Deadly 提交于 2019-11-29 00:05:58
Raghav Sood

(from this answer and its comments)

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

@android:color/black

means you are referring to an color defined in the android namespace. This namespace is the namespace of the framework.

search black in this file: black color in framework

style="?android:attr/borderlessButtonStyle"

"?android:attr/borderlessButtonStyle" simply means "use the value defined by the attribute called borderlessButtonStyle in the namespace android." This attribute and its value are part of the Android framework, the "android" namespace.

borderlessButtonStyle in framework


Edited: from this Referencing Style Attributes

this link tell us:

For example, here's how you can reference an attribute to set the text color to match the "primary" text color of the system theme:

<EditText id="text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textColor="?android:textColorSecondary"
    android:text="@string/hello_world" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!