Toolbar behind status bar

两盒软妹~` 提交于 2019-12-06 07:15:22

问题


I had a problem with toolbar and status bar. I change the app styles to AppCompat. My styles are:

for values/styles.xml

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

        <item name="colorPrimary">@color/color_primario_500</item>
        <item name="colorPrimaryDark">@color/color_primario_500</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>

</style>

for values-v21/styles.xml:

<style name="AppTheme" parent="AppTheme.BaseGps">
        <item name="android:windowContentTransitions">true</item>
        <item name="android:windowAllowEnterTransitionOverlap">true</item>
        <item name="android:windowAllowReturnTransitionOverlap">true</item>
        <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
        <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
        <item name="android:windowTranslucentStatus">true</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>

My problem is that half the toolbar appears behind status bar. In the next image you can see what happens.

Any ideas? Thanks in advance!!


回答1:


The solution is apply the item

<item name="android:windowTranslucentStatus">false</item>

in the styles.




回答2:


I don't like these answers. Just because with Material design a Navigation Drawer should overlap the toolbar and have a translucent status bar so long as the API level supports it.

If you want the toolbar to fit properly and have a translucent status bar then you just need these items in your style.

    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:windowTranslucentStatus">true</item>


来源:https://stackoverflow.com/questions/31133552/toolbar-behind-status-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!