Search code examples
androidnavigationstatusbardrawer

Android Lollipop transparent statusbar


My problem is easy but I need some help I have a MainActivity, several Fragments and NavigationDrawer. I also use a Appcompat v7 NavigationDrawer is shown behind the statusbar for what I use ScrimInsetsLayout. In styles I have colorPrimary and colorPrimaryDark(parent is Theme.Appcompat)

In main activity I use setStatusBarColor(Color.TRANSPARENT) to show Drawer in statusbar. So now I have colorPrimaryDark statusbar color and NavigationDrawer in statusbar

Now I created a new Fragment and I need to disable colorPrimaryDark color and make statusbar real transparent

As I said before, setting color to transparent makes it colorPrimaryDark with drawer shown

Setting it to any other color "hides" drawer.

Thanks

Screenshots:

Screen1 Screen1 Screen1


Solution

  • The transparent translucent status bar is available from API 19, create a new values-v19 folder and a styles.xml inside it then update your BaseAppTheme like this:

    <!-- Base application theme for v19. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowTranslucentNavigation">false</item>
        <item name="android:windowTranslucentStatus">true</item>
    </style>
    

    But, this would make your UI use the space behind StatusBar, so I would suggest adding an extra TOP padding, of 25dp (researched and found every API uses 25dp as StatusBar height even in landscape mode), for devices > API19