【问题标题】:Difference between ?selectableItemBackground, ?android:selectableItemBackground and ?android:attr/selectableItemBackground in Android?Android 中 ?selectableItemBackground、?android:selectableItemBackground 和 ?android:attr/selectableItemBackground 之间的区别?
【发布时间】:2015-09-28 09:15:33
【问题描述】:

有什么区别:

android:background="?selectableItemBackground"

android:background="?attr/selectableItemBackground"

android:background="?android:selectableItemBackground"

android:background="?android:attr/selectableItemBackground" 

在安卓系统中?

【问题讨论】:

    标签: android android-xml


    【解决方案1】:

    这里,

    android:background="?selectableItemBackground"
    

    是来自 appCompat 库的属性引用,因此它适用于旧版本的 android,不需要 android 前缀。

    android:background="?android:selectableItemBackground"
    

    是平台提供的属性,可能不支持较旧的android版本,但仅支持它们引入的版本。

    android:background="?android:attr/selectableItemBackground"
    

    这里使用的attr 适用于为当前主题定义的属性。即,如果您将应用程序主题设置为轻版本,则将应用轻主题的 selectableItemBackground。

    您可以定义自己的值,无需使用 android 前缀即可访问。

    【讨论】:

    • 谢谢,@subhash。你能提供文档的链接吗?
    【解决方案2】:

    他们都做同样的工作。唯一的区别是 android 前缀适用于 android 3.0 及更高版本,如果您想为 android 2.3 及更低版本使用相同的属性,则必须删除 android 前缀。谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-20
      • 1970-01-01
      相关资源
      最近更新 更多