【问题标题】:ColorPrimaryDark Not comming as a Status bar colorColorPrimaryDark 不作为状态栏颜色出现
【发布时间】:2017-05-02 07:30:44
【问题描述】:

我在应用程序中有两个样式文件,它没有将 colorPrimaryDark 作为状态栏颜色。我正在检查 Nexus 6,但它无法在其中工作。这是我缺少的东西。

style.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>


    </style>


</resources>

style.xml(v21)

<resources>

    <!-- Base application theme. -->
    <!--Application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowDrawsSystemBarBackgrounds">false</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <!--All customizations that are NOT specific to a particular API-level can go here. -->
    </style>


</resources>

Menifest - 在任何活动中都没有定义主题

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

颜色文件

<color name="colorPrimary">#35734F</color>
    <color name="colorPrimaryDark">#35734F</color>
    <color name="colorAccent">#D2AB67</color>

【问题讨论】:

  • 发布颜色 xml 和清单文件
  • 代码现已更新.. @FerdousAhamed

标签: android android-toolbar android-appcompat android-styles android-statusbar


【解决方案1】:

尝试在您的style.xml(v21) 中添加&lt;item name="android:windowDrawsSystemBarBackgrounds"&gt;true&lt;/item&gt;&lt;item name="android:statusBarColor"&gt;@android:color/transparent&lt;/item&gt;

style.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme" parent="AppBaseTheme">

</resources>

style.xml(v21)

<resources>

    <!-- Base application theme. -->
    <!--Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
        <item name="android:statusBarColor">@android:color/transparent</item>
    </style>

</resources>

【讨论】:

【解决方案2】:

将父级更改为“Theme.AppCompat.Light.NoActionBar”

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>

</style>

</resources>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多