Reputation: 340
I want to change color of navbar and status bar in Android 5 Lolipop app.
Here are my manifest sdk settings:
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="21"
android:maxSdkVersion="21" />
I have this in my my_style.xml file :
<?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>
If I change android:colorPrimary
color of bar (not status bar/navbar) also changes on layout in IDE and when debugging Android app, but statusBarColor
and navigationBarColor
doesn't do anything (https://developer.android.com/training/material/theme.html - here you can see that it should). I even tried to do:
getWindow.setStatusBarColor(Integer.parseInt("00FF00", 16))
but it also doesn't work. Am I missing something ?
Upvotes: 1
Views: 872
Reputation: 340
I solved that by adding flag ( Scala code ):
getWindow.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
before
setContentView(R.layout.main)
it works in app, but still layout editor doesn't show changes of android:statusBarColor
and android:navigationBarColor
items in app_style.xml
Upvotes: 1