状态栏和导航栏颜色不会改变
问题描述:
我想更改Android 5 Lolipop应用中导航栏和状态栏的颜色。状态栏和导航栏颜色不会改变
这里是我的清单SDK设置:
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="21"
android:maxSdkVersion="21" />
我有这个在我的my_style.xml文件:如果我改变android:colorPrimary
彩条(未状态栏/导航栏)的
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- inherit from the material theme -->
<style name="AppTheme" parent="android:Theme.Material">
<!-- 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>
<item name="android:statusBarColor">@color/navbar</item>
<item name="android:navigationBarColor">@color/navbar</item>
</style>
</resources>
也IDE中布局的变化以及调试Android应用程序时的变化,但statusBarColor
和navigationBarColor
不会执行任何操作(在这里您可以看到它应该)。我甚至试过:
getWindow.setStatusBarColor(Integer.parseInt("00FF00", 16))
但它也不起作用。我错过了什么吗?
答
我解决了通过添加标志(Scala代码):
getWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
前
setContentView(R.layout.main)
它在应用程序,但仍然布局编辑器不会显示和android:statusBarColor
变化android:navigationBarColor
项目app_style.xml
你是如何得到'getWindow'工作的?对我来说它说无法解析符号'getWindow'? – TheOddAbhi 2014-12-07 05:03:49
getWindow是在斯卡拉,在Java中你可能想getWindow() – myhau 2014-12-15 08:48:33
我能够解决它的另一种方式。 – TheOddAbhi 2014-12-15 08:52:48