【问题标题】:How can I change statusbar color without a toolbar?如何在没有工具栏的情况下更改状态栏颜色?
【发布时间】:2015-10-06 11:10:55
【问题描述】:

我正在尝试使状态栏颜色 #a1a1a1 (white_dark),但当我运行它时它只是黑色。

这是我的 Style v21 文件:

    <style name="AppBaseTheme" parent="AppTheme">
         <item name="android:windowDrawsSystemBarBackgrounds">true</item>
         <item name="android:statusBarColor">@color/white_dark</item>
    </style>

【问题讨论】:

  • 尝试设置这个&lt;item name="colorPrimaryDark"&gt;@color/your_color&lt;/item&gt;
  • 大家好,这不起作用,因为我禁用了我的工具栏...

标签: android toolbar statusbar


【解决方案1】:

你可以试试这个lib

但我个人的建议是,切换到AppCompat,因为它很容易改变StatusBar的颜色。

主要深色用于StatusBar

<!-- darker variant for the status bar and contextual app bars -->
<item name="colorPrimaryDark">@android:color/black</item>

【讨论】:

    【解决方案2】:

    使用这个主题

    <resources>
        <!-- the theme applied to the application or activity -->
        <style name="CustomActionBarTheme"
            parent="@style/Theme.AppCompat.Light.DarkActionBar">
            <item name="android:actionBarStyle">@style/MyActionBar</item>
    
            <!-- Support library compatibility -->
            <item name="actionBarStyle">@style/MyActionBar</item>
        </style>
    
        <!-- ActionBar styles -->
        <style name="MyActionBar"
            parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
            <item name="android:background">@color/atctionbar_color</item>
    
            <!-- Support library compatibility -->
            <item name="background">@color/atctionbar_color</item>
        </style>
    </resources>
    

    并在 values>colors.xml 中创建新文件并从那里添加颜色

    <resources>
        <color name="atctionbar_color">#170053</color>
    </resources>
    

    【讨论】:

      猜你喜欢
      • 2020-01-17
      • 2018-07-04
      • 1970-01-01
      • 1970-01-01
      • 2020-02-14
      • 1970-01-01
      • 2015-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多