什么是以下两者之间的区别:
android:background="?selectableItemBackground"
android:background="?attr/selectableItemBackground"
android:background="?android:selectableItemBackground"
android:background="?android:attr/selectableItemBackground"
在安卓(Android)中吗?
什么是以下两者之间的区别:
android:background="?selectableItemBackground"
android:background="?attr/selectableItemBackground"
android:background="?android:selectableItemBackground"
android:background="?android:attr/selectableItemBackground"
在安卓(Android)中吗?
这里,
android:background="?selectableItemBackground"
这是来自appCompat库的属性引用,因此适用于较旧版本的Android,并且不需要android前缀。
android:background="?android:selectableItemBackground"
属性由平台提供,可能不支持较旧版本的Android,只支持从特定版本开始的版本。
android:background="?android:attr/selectableItemBackground"
此处使用attr应用于当前主题定义的属性。即,如果您的应用程序主题设置为浅色版本,则将应用浅色主题的selectableItemBackground。
并且您可以定义自己的值,无需使用android前缀即可访问。
它们都做同样的工作。唯一的区别是,android前缀适用于android 3.0及以上版本,如果您想在android 2.3及以下版本中使用相同的属性,则必须删除android前缀。谢谢