Android 4.4和5.0中的不同状态栏样式

Android 4.4和5.0中的不同状态栏样式,android,android-5.0-lollipop,android-4.4-kitkat,material-design,translucentdecor,Android,Android 5.0 Lollipop,Android 4.4 Kitkat,Material Design,Translucentdecor,当应用程序在Kitkat设备上运行时,如何设置状态栏的半透明模式;当应用程序在棒棒糖设备上运行时,如何设置不同的颜色模式 这是values and values-v21文件夹中的my styles.xml: <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">#2196F3</item> <item n

当应用程序在Kitkat设备上运行时,如何设置状态栏的半透明模式;当应用程序在棒棒糖设备上运行时,如何设置不同的颜色模式

这是values and values-v21文件夹中的my styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">#2196F3</item>
    <item name="colorPrimaryDark">#0D47A1</item>
</style>
<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>

#2196F3
#0D47A1
这是values-v19文件夹中的my styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">#2196F3</item>
    <item name="colorPrimaryDark">#0D47A1</item>
</style>
<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>

#2196F3
#0D47A1
真的
真的

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

res/values-vXX
您使用的是styles-v19.xml和styles-v21.xml:这是不同的

例如,请使用以下内容:

res/values/styles.xml
res/values-v19/styles.xml
res/values-v21/styles.xml

在值xx中创建styles.xmlfolder@HarshaVardhan我创建了styles.xml、styles-v19.xml和styles-v21.xml,但它不起作用。styles.xml和styles.xml的添加代码应该在值-{version}中folder@HarshaVardhanAndroid Studio不需要这些。是吗?这不是关于IDE,而是关于android的结构。如果您想采用样式,则取决于版本。我们需要遵循我的断层定义的结构。我没有正确地显示它。我使用Android Studio,它会隐藏值-{version}文件夹。相反,它只是显示styles.xml(version)。@ywwynm您使用的是“Android”视图。在本例中,您将看到带有(#number)的styles.xml。您可以分解此部分。如果您想查看文件夹结构,可以使用“项目”视图。查看左上角的视图。我理解你的想法,但我非常确定没有错误。所有my styles.xml都在它们应该在的地方。