什么是之间和的差额QUOT;安卓?"和" @android:"在Android的布局XML文件?
什么是之间的区别在Android的布局XML文件机器人:?:和@android?他们似乎是重复使用Android SDK中的资源互换的方式。
What's the difference between "?android:" and "@android:" in an android layout xml file? They seem to be interchangeable ways of reusing android SDK resources.
我发现的唯一的差异是由以下例子所示。
The only difference I discovered is illustrated by the following example.
下面TextView的的右边缘与所述的ImageButton的左边缘对齐呈现
Here the TextView's right edge is rendered aligned with the left edge of the 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。
Here, however, the right edge of the TextView is aligned with the right edge of the RelativeLayout. The TextView overlaps the 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?机器人。双方没有错误编译。
The only difference between the two layouts is the use of @android vs ?android. Both compile with no errors.
谢谢了。
prefixing带有问号的号码表示要访问硬编码的属性,它是在一个风格的主题定义的样式属性,而不是
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.
请参阅引用样式属性在这里:accessing-resources
See "Referencing Style Attributes" here: accessing-resources