首页 > 解决方案 > 在Android中更改菜单抽屉汉堡图标的颜色

问题描述

我想更改汉堡图标的图标颜色。我尝试了很多东西,但没有任何效果。这是我的XML

<androidx.appcompat.widget.Toolbar
 android:layout_width="match_parent"
 android:layout_height="?attr/actionBarSize"
 android:background="@color/colorPrimary"
 app:titleTextColor="@color/colorPrimaryDark"
 android:id="@+id/toolbar"
 android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
 app:popupTheme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
 android:elevation="4dp"/>

styles.xml我有

<style name="AppTheme" 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="android:windowDrawsSystemBarBackgrounds">true</item>
  <item name="android:statusBarColor">@android:color/transparent</item>
</style>

标签: androidcolors

解决方案


看起来您正在使用 AppCompat。请创建此或类似样式:

<style name="DrawerArrowStyle" parent="@style/Widget.AppCompat.DrawerArrowToggle">
    <item name="color">#D81B60</item>
</style>

然后在你的主题中使用它:

<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>

推荐阅读