简体   繁体   中英

toolbar overlays status bar

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

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.

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

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM