在android layout xml文件中,“?android:”和“@android:”有什么区别?它们似乎是重用android SDK资源的可互换方式。在android layout xml文件中,“?android:”和“@android:”有什么区别?
我发现的唯一区别是由以下示例说明的。
这里的TextView的右边缘与呈现的ImageButton的
<RelativeLayout
android:id="@id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#888888">
<TextView
android:id="@android:id/text1"
android:layout_alignParentLeft="true"
android:text="blah blah"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@android:id/button1" />
<ImageButton
android:id="@android:id/button1"
android:layout_alignParentRight="true"
style="@style/PlusButton" />
</RelativeLayout>
这里左边缘对齐,但是,TextView的右边缘与RelativeLayout的右边缘对齐。 TextView与ImageButton重叠。
<RelativeLayout
android:id="@id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#888888">
<TextView
android:id="@android:id/text1"
android:layout_alignParentLeft="true"
android:text="blah blah"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="?android:id/button1" />
<ImageButton
android:id="?android:id/button1"
android:layout_alignParentRight="true"
style="@style/PlusButton" />
</RelativeLayout>
这两个布局的唯一区别是使用@android vs?android。两种编译都没有错误。
非常感谢。
[(?)问号Android版XML属性(可能的重复http://stackoverflow.com/questions/2733907/question-mark-in- xml-attributes-for-android) – 2016-02-20 04:06:18