Search code examples
javaandroidstatusbartranslucencyandroid-statusbar

Cannot make status bar translucent


EDIT: The more relevant question is posted here: MaterialDrawer library turns a translucent status bar into a opaque one


I know it can be done in API19+. Also I have read this and this and it seems that it can be done very easily. However I can't get it done. Here is my theme in values-v19 folder:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="android:windowTranslucentStatus">true</item>
    <item name="android:windowTranslucentNavigation">true</item>
</style>

I have also changed the appcompat theme to Theme.Holo.Light.NoActionBar.TranslucentDecor (and of course using Activity instead of AppCompatActivity); Nothing changed.

This is the screen shot from genymotion emulator api-22 (solid status bar; same result on real device):

enter image description here

And now here's the weird thing: In the preview window of the layout, when you select api-23 (on both appcompat and holo themes), I get this result (translucent):

enter image description here

and the preview for api-19 (also api-21 and 22) is this:

enter image description here

It's very confusing and I don't know what have I done wrong. Any help would be appreciated.

EDIT:

If I add:

<item name="colorPrimaryDark">@color/primary_dark</item>

the solid status bar changes color:

enter image description here

The other weird thing is the navigation drawer goes beyond the damn bar:

enter image description here


Solution

  • I finally found the source of the problem. I was using MaterialDrawer library for adding a drawer to my activity. When I removed it, everything worked perfectly. I will post another question to issue this problem and will add the link to that in an edit.