简体   繁体   English

工具栏覆盖状态栏

[英]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. true状态栏显示为透明,但问题是状态栏上的工具栏重叠。 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. 我使用true解决了问题,但状态栏显示为灰色,而不是我设置的原色。 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. 这是因为您还指定了<item name="android:fitsSystemWindows">true</item> ,从而告诉Android您要自己处理系统UI(例如状态栏)。

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 请检查此链接我还回答了类似的问题您可以将statusBar颜色设置为透明

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. 在Styles-v21中添加尺寸为25dp,在样式0dp中添加尺寸。您必须添加该尺寸的额外布局作为工具栏上方具有所需颜色的高度。

My Styles.xml 我的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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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