android - 为什么 backgroundTint 需要 android : prefix after API 21 but not before?

标签 android xml-namespaces android-styles

声明样式时,当我定义一个项目 android:backgroundTint 时,我收到一条警告,指出它从 API 21 开始可用,而我指定的最低 API 较低 (API 17)。另一方面,当我将其替换为简单的 backgroundTint 时,警告消失了。有谁知道这是为什么吗?

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:backgroundTint">#0F0</item>
</style>

除此之外,如果我对单个组件(例如按钮)使用 android:backgroundTint,无论我的项目的最低 SDK 是多少,我都不会收到任何警告或错误。这有点令人费解。

最佳答案

我知道这是一个老问题,但如果你关注 this solution指示我们将 android:backgroundTint 更改为 app:backgroundTint,您将摆脱以下警告:

Attribute backgroundTint is only used in API level 21 and higher

关于android - 为什么 backgroundTint 需要 android : prefix after API 21 but not before?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48825405/

相关文章:

android - adb reboot 挂起 Genymotion

java - JAX-B 正在编码一切

java - 在 Java 中尝试使用正则表达式提取 XMLNS

android - 工具栏标题中有多种颜色?

android - 如何自定义 float ActionBar的背景?

android - 在应用程序之间传输文件 (.txt)

Android 和 XML map

android形状不改变大小

android - 找不到 aapt。请确保您已安装 Android 构建工具

wcf - 在 WCF 中更改命名空间和 schemaLocation 属性