【发布时间】:2019-03-14 17:26:44
【问题描述】:
首先,我想澄清一下,我愿意更改汉堡导航菜单图标本身的颜色,而不是导航菜单中的图标。
我遵循了这个教程:https://developer.android.com/training/implementing-navigation/nav-drawer#DrawerButton
因此,我在应用栏中有一个 NavMenu 图标(汉堡)。问题:图标为黑色(Vector drawable 的默认颜色)。
我创造了一种新风格:
<!-- Hamburger menu -->
<style name="MyDrawerArrowToggle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="color">@color/colorTextTitle</item>
</style>
然后我将此样式添加到我的主题中:
<style name="customTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Hamburger menu -->
<item name="drawerArrowStyle">@style/MyDrawerArrowToggle</item>
</style>
确保此样式是我的应用在清单中使用的样式:
<application>
android:theme="@style/customTheme"
</application>
并且还将这个主题应用于工具栏(以防万一……)
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorToolbarBackground"
app:theme="@style/customTheme"
app:popupTheme="@style/customTheme"
app:title="@string/app_name"
app:titleTextColor="@color/colorTextBody">
</android.support.v7.widget.Toolbar>
</FrameLayout>
操作结果:这些都没有任何效果。汉堡包图标仍然非常黑。
谁能向我解释我犯了什么错误以及如何改变这种颜色?
【问题讨论】: