如何在 Android 导航抽屉中显示图标的原始颜色?

How to show original color of icon in Android Navigation drawer?

我创建了一个新的 Android Studio 项目并选择了 Navigation drawer activity

activity_main_drawer.xml 中,我将图标路径更改为 drawable 文件夹中的文件,如下所示

<item
    android:id="@+id/nav_camera"
    android:icon="@drawable/nav_logo_premium"
    android:title="Import" />

它改变了图标。但它不显示原始颜色。它显示为 灰颜色 我想我需要更改主题。花了几个小时我找不到解决方案。

非常感谢任何形式的帮助。

Because i did not change code I did not attached all files source code here

请看附件截图 Screenshot

在您的 styles.xml

中创建这样的样式
<style name="drawStyle" parent="Widget.AppCompat.DrawerArrowToggle">
    <item name="color">@android:color/red</item>
</style>

将创建的样式添加到您的主主题中,这会更改切换按钮的颜色。

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

如果您使用设计支持库,您可以使用 app:itemIconTint 属性:

更改图标颜色
<android.support.design.widget.NavigationView
    android:id="@+id/navigation"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme"
    app:headerLayout="@layout/header"
    app:itemIconTint="#f00"
    app:itemTextColor="#0f0"
    app:menu="@menu/left_menu" />

强制 NavigationView 停止为 MainActivity.java 中的图标着色:

NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setItemIconTintList(null);

删除 android:fillColor="#FF000000" 来自 V21/ic_menu_slideshow.xml 如果可用