声明一个样式,当我定义一个 item 时android:backgroundTint,我收到一个警告,它从 API 21 开始可用,而我指定的最小 API 较低(API 17)。另一方面,当我用 simple 替换它时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>
Run Code Online (Sandbox Code Playgroud)
除此之外,如果我android:backgroundTint用于单个组件,例如按钮,则无论我的项目的最低 SDK 是什么,我都不会收到警告或错误。这有点令人费解。
我想为状态栏着色,以便在Android 5.0中更好看.我想设置三种颜色的primarydark,light和accent.
但我的最低API是15.有没有机会在API lvl 21下使用它?或者我必须用min创建一个单独的应用程序.sdk 21?
编辑:现在我得到我需要的一切,但statisbar颜色不会改变.
这是我的values-v21/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="android:Theme.Material.Light">
<!-- API 21 theme customizations can go here. -->
<!-- Main theme colors -->
<!-- your app branding color for the app bar -->
<item name="android:colorPrimary">@color/primary</item>
<!-- darker variant for the status bar and contextual app bars -->
<item name="android:colorPrimaryDark">@color/primary_dark</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">@color/accent</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
这是普通的style.xml
<resources>
<!--
Base application theme, dependent on API level. This …Run Code Online (Sandbox Code Playgroud)