android - 在支持 v7 的 xml 中应用 selectableItemBackground [英] android - apply selectableItemBackground in xml with support v7
问题描述
即使我的应用程序中包含 android 支持 v7
even with android support v7 included in my application
添加android:background="?android:attr/selectableItemBackground"
使我的 IDE、Eclipse 抛出错误(阻止我编译),通知我 selectableItemBackground 仅适用于最低 Api 11 及更高版本.
makes my IDE, Eclipse throw an error (preventing me from compiling), notifying me that selectableItemBackground is only for min Api 11 and up.
如何在 XML 中将此属性添加到背景中?
How do I add this attribute to a background in XML?
假设从更高的库复制和粘贴不是解决方案
assume that copying and pasting from a higher library is not a solution
推荐答案
由于属性是在库中定义的(支持 v7),您可以将其用作用户定义的属性:即没有 android:
前缀:
Since the attribute is defined in a library (support v7), you would use it as a user-defined attribute: i.e without the android:
prefix:
android:background="?attr/selectableItemBackground"
您看到的错误指出 ?android:attr/selectableItemBackground
可用于 API 版本 >= 11.确实如此.
The error you see is pointing out that ?android:attr/selectableItemBackground
is available for API versions >= 11. True, indeed.
这篇关于android - 在支持 v7 的 xml 中应用 selectableItemBackground的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!