2

如何在 Kitkat 设备上运行应用程序时为状态栏设置半透明模式,在 Lollipop 设备上运行应用程序时如何设置不同颜色模式?

这是我在 values 和 values-v21 文件夹中的 styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">#2196F3</item>
    <item name="colorPrimaryDark">#0D47A1</item>
</style>

这是我在 values-v19 文件夹中的 styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">#2196F3</item>
    <item name="colorPrimaryDark">#0D47A1</item>
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>
4

1 回答 1

3

如果您要为不同的 API 版本创建不同的样式,则必须使用不同的文件夹而不是不同的文件名。

res/values-vXX

您使用的是styles-v19.xml 和styles-v21.xml:不一样!

例如使用类似的东西:

res/values/styles.xml
res/values-v19/styles.xml
res/values-v21/styles.xml
于 2015-04-16T06:25:21.430 回答