【问题标题】:Appcombat v7 Toolbar with drawer changing colorsAppcompat v7 工具栏与抽屉改变颜色
【发布时间】:2014-12-11 13:28:49
【问题描述】:

我正在我的应用程序上实现材料设计,我希望能够将抽屉图标的颜色更改为白色,但我无法实现我想要的......

这是我的主题.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="AppTheme" parent="AppTheme.Base" />

    <style name="AppTheme.Base" parent="Theme.AppCompat.Light">
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primary_dark</item>
        <item name="android:windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
    </style>

    <style name="HeaderBar" parent="AppTheme.Base">
        <item name="android:textColorPrimary">@android:color/white</item>
        <item name="android:background">@color/primary</item>
        <item name="actionMenuTextColor">@android:color/white</item>
        <item name="android:textColorSecondary">@android:color/white</item>
        <item name="android:actionMenuTextColor">@android:color/white</item>
    </style>

    <style name="ActionBarPopupThemeOverlay" parent="ThemeOverlay.AppCompat.Light">
        <item name="android:background">@android:color/white</item>
        <item name="android:textColor">#000</item>
    </style>

    <style name="ActionBarThemeOverlay" parent="">
        <item name="android:textColorPrimary">#fff</item>
        <item name="colorControlNormal">#fff</item>
        <item name="colorControlHighlight">#3fff</item>
    </style>

</resources>

这是我的toolbar.xml文件

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res/jpe.serviguide.commobile"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    app:popupTheme="@style/ActionBarPopupThemeOverlay"
    app:theme="@style/HeaderBar" />

我想要的所有颜色都很好,但抽屉图标是黑色而不是白色..

我尝试了很多东西,但没有任何结果

非常感谢

【问题讨论】:

标签: android android-appcompat material-design


【解决方案1】:

终于在我的 theme.xml 文件上这样做了

<style name="AppTheme" parent="Theme.AppCompat.Light">
    ....
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="spinBars">true</item>
    <item name="color">@android:color/white</item>
</style>

【讨论】:

  • @LisaAnne 很高兴为您提供帮助! :)
【解决方案2】:

你可以这样做:

    <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimaryDark"
        android:minHeight="?attr/actionBarSize"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />

app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" - 很重要的部分

【讨论】:

    【解决方案3】:

    我认为您的操作栏应该具有以下父级 (ThemeAppCompat.Light):

    <style name="HeaderBar" parent="Theme.AppCompat.Light">
        <item name="android:textColorPrimary">@android:color/white</item>
        <item name="android:background">@color/primary</item>
        <item name="actionMenuTextColor">@android:color/white</item>
        <item name="android:textColorSecondary">@android:color/white</item>
        <item name="android:actionMenuTextColor">@android:color/white</item>
    </style>
    

    【讨论】:

      【解决方案4】:

      您好 neteot,当我使用服装栏时,我创建了一个自定义布局作为栏,然后在我的情况下,栏按钮/汉堡按钮是一个 ImageButton... 然后你需要更改图标的颜色

      如果你想创建一个完美的自定义栏,你可以看看我的最后一个帖子:

      https://stackoverflow.com/questions/27417923/android-add-custom-buttons-on-action-bar/27418306#27418306

      祝你好运,我等着帮你!

      PD:如果您需要更多信息或有任何疑问,请告诉我!

      【讨论】:

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