Android的 - 与支持V7在XML应用selectableItemBackgroundAndroid、selectableItemBackground、XML

2023-09-12 02:58:45 作者:爱拼才会赢

即使有支持Android V7包含在我的应用程序

even with android support v7 included in my application

添加 安卓背景=机器人:ATTR / selectableItemBackground

让我的IDE,Eclipse将抛出一个错误($ P $的编译pventing我),通知我说selectableItemBackground仅用于分钟阿比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)定义,你可以使用它作为一个用户定义的属性:即没有机器人: preFIX:

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"

您看到的错误是指出安卓?ATTR / selectableItemBackground 适用于API版本> = 11,真正的,确实

The error you see is pointing out that ?android:attr/selectableItemBackground is available for API versions >= 11. True, indeed.