我希望为Android 5.0上的状态栏着色,以使其外观更好看。我想设置三种颜色:primarydark、light和accent。
但我的最低API是15。是否有可能在API级别21以下仅使用此功能?或者我必须创建一个具有最小sdk 21的单独应用程序?
编辑: 现在我已经得到了我需要的一切,但状态栏颜色不会改变。
这是我的values-v21/styles.xml。
这是普通的style.xml文件。
任何想法为什么这行代码不起作用?
但我的最低API是15。是否有可能在API级别21以下仅使用此功能?或者我必须创建一个具有最小sdk 21的单独应用程序?
编辑: 现在我已经得到了我需要的一切,但状态栏颜色不会改变。
这是我的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>
这是普通的style.xml文件。
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@color/blue</item>
</style>
</resources>
任何想法为什么这行代码不起作用?
colors.xml
文件? - ipavl