问号对我来说很新鲜

时间:2012-11-10 20:57:37

标签: java android xml android-layout

这个

<TextView
xmlns:android=”http://schemas.android.com/apk/res/android”
android:id=”@+id/separator”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:gravity=”center”
style=”?android:attr/listSeparatorTextViewStyle” />

或者

   <item name="android:textColor">?textColorSecondary</item>

有时候我会在xml节点的内容中看到问号,我不知道它是什么,没有文档对吗?

1 个答案:

答案 0 :(得分:3)

?引用当前主题中的资源,它在开发人员指南Accessing Resources中有所描述:

  

样式属性资源允许您引用当前应用主题中的属性值。引用样式属性允许您通过设置UI元素的样式来自定义UI元素的外观,以匹配当前主题提供的标准变体,而不是提供硬编码值。引用样式属性实质上是说,“在当前主题中使用由此属性定义的样式。”

     

要引用样式属性,名称语法几乎相同   正常的资源格式,但使用问号(?)代替at符号(@),资源类型部分是可选的。例如:

?[<package_name>:][<resource_type>/]<resource_name>