Search code examples
androidandroid-actionbarandroid-statusbar

Status bar cover action bar in Android


I want my status bar to be transparent and match action bar color. But for different activities I have diffenrent color for action bar so I can't use "colorPrimaryDark" for my status bar. How to achive this?

v21\styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimaryDark">@android:color/transparent</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:windowTranslucentStatus">true</item>
</style>
<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

Activities has "android:fitsSystemWindows="false""

This is what I have enter image description here And this is what I want enter image description here

Same for other colors in action bar.

Any help?


Solution

  • This is the normal behavior - this command is for use cases when you want a picture that can't be stretched out behind the status bar like here.
    Solution-

    1. In my opinion from the picture just change the status bar color:

    <item name="android:statusBarColor">@android:color/Red</item>
    

    2. Increase the height of your action bar by 25dp (status bar height).