2

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

Tomas
  • 4,652
  • 6
  • 31
  • 37
Emin Guliev
  • 188
  • 2
  • 11

1 Answers1

13

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

Ankit Bansal
  • 1,801
  • 17
  • 34
  • Thanks for a fast reply. I have tried this also, but I still have colorPrimaryDark behind it. So I have a statusbar color even darker then colorPrimaryDark – Emin Guliev May 05 '15 at 11:17
  • If you are trying to make a replica of iOS app, then first go through what you can/cannot have in Android. Complete transparent StatusBar is not possible in Android. http://developer.android.com/about/versions/android-4.4.html#UI – Ankit Bansal May 05 '15 at 11:33
  • No, my goal is Translucent statusbar, I understand that transparent is not possible. When I make iTtranslucent it is not actually translucent. Feels like I have colorPrimaryDark behind the translucent statusbar. And one more point. If I don't use setStatusBarColor I have translucent:) – Emin Guliev May 05 '15 at 11:36
  • can you post a screenshot of what you have and what you desire – Ankit Bansal May 05 '15 at 11:37
  • http://imgur.com/AOJFL8C http://imgur.com/uUCXcBt http://imgur.com/ATPEXfg now I have pink statusbar. I want to keep it in "Friends" fragment and make translucent in profile fragment – Emin Guliev May 05 '15 at 11:41
  • Okay, they you can do this programmatically while switching fragments, use code given here http://stackoverflow.com/a/19792838/3485152 – Ankit Bansal May 05 '15 at 11:55