2

I am trying to make status bar transparent by using
true The status bar shows transparent but the problem is toolbar overlays on the status bar. Toolbar is half visible goes behind status bar. I solved that using true but the status bar appears in gray color not the primary color which I have set. What's wrong??

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="colorPrimary">@color/primary_500</item>
    <item name="colorPrimaryDark">@color/primary_700</item>

    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:fitsSystemWindows">true</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowTranslucentStatus">true</item>

</style>

this is my theme

3 Answers3

0

This is because you are also specifying <item name="android:fitsSystemWindows">true</item>, telling Android that you want to handle the system UI (such as the status bar) yourself.

If you remove that element you should find that your Toolbar lies below the status bar.

If you had that there for a reason, you will need to update your layout to actually account for the status bar.

Bryan Herbst
  • 66,602
  • 10
  • 133
  • 120
  • @Tanis--- If I remove true, this, then the toolbar dose not come belw status bar –  Sep 03 '15 at 16:38
  • Do you also happen to be using a CollapsingToolbarLayout? If so, you might be looking for this question: http://stackoverflow.com/questions/30882429/using-windowtranslucentstatus-with-collapsingtoolbarlayout – Bryan Herbst Sep 03 '15 at 16:40
  • Or you may be using `fitsSystemWindows` in your layout elsewhere- check for any other usages of it. – Bryan Herbst Sep 03 '15 at 16:41
  • No its just a toolbar and navigation view –  Sep 03 '15 at 16:42
0

please check at this link I have answered similar question in addition You can set statusBar color as transparent

How to remove this gray color from topbar/status bar

Community
  • 1
  • 1
Shishram
  • 1,514
  • 11
  • 20
  • Removing this true true helps to remove the gray color. But I want to make status bar transparent over the navigation drawer. It can be achieved using true this only right?? –  Sep 05 '15 at 11:22
-1

Add a dimension in Styles-v21 it is 25dp and in styles 0dp You have to add extra layout with that dimen as height above toolbar with required color.

My Styles.xml

<style name="AppTheme.MovieDetails" parent="AppTheme.Base">
        <!-- Customize your theme here. -->

        <item name="android:textColorPrimary">@android:color/white</item>
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        <item name="android:windowTranslucentStatus" tools:targetApi="21">true</item>
        <item name="android:windowContentOverlay">@null</item>

        <!-- Toolbar Theme / Apply background_with_ripple arrow -->
        <item name="colorControlNormal">@android:color/white</item>
        <item name="actionBarTheme">@style/AppTheme.ActionBarTheme</item>

        <!-- Material Theme -->
        <item name="android:navigationBarColor" tools:targetApi="21">@color/navigationBarColor
        </item>
        <item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="21">true</item>
    </style>
Ashok Varma
  • 3,489
  • 3
  • 28
  • 43