I'm using the AppCompat-v7:21.0.0
support library for Android 5.0 Lollipop in Android Studio. My problem is that the Status Bar Color that can be changed by setting colorPrimaryDark
in the values/styles.xml
file, is showing up as black, in both the xml layout preview and the emulator.
So what's wrong? Am I missing something? Please let me know. Thanks.
EDIT: I'm aware of the fact that changing the status bar color on Pre-Lollipop versions is not possible. My XML Layout Editor Preview and my Emulator are both set to API Level 21 (5.0 Lollipop). But, the status bar still isn't of the color I set it to in colorPrimaryDark
. I tried doing statusBarColor
in styles.xml
but to no avail. It's still black.
ALSO: I saw one of the answers on a similar question where they advised me to put my minSdkVersion
to 21. I tried that, but it didn't work. And I want my app to run on devices with API Level 15 and above.
Changing the Status Bar color in pre-Lollipop(5.0) is not possible by setting colorPrimaryDark. See this article.
Please read this: For this to take effect, the window must be drawing the system bar backgrounds with
but
must not be set (Source)
In case of you don't know how to add that flag:
Did you set the target SDK version to 21? I had the same issue when I left the target SDK version to 19. You can leave the min SDK to anything lower.
And of course you need to inherit from the proper theme and make sure your Activity uses it.
I was working on an old app and trying to convert it to material style. The code and everything was fine however the only mistake I had that was hindering the status bar tinting on >= Lollipop devices was "TargetSDKVersion" in build.gradle. It was set to less then 21. I changed it to 21 and statusbar tinting started working.
This worked for me:
In my case, the culprit was
jfeinstein10/SlidingMenu
library. I replaced the library withAndroid navigation drawer
and now it displays status bar color correctly.