自定义默认导航抽屉 Activity 矢量图标

Customising Default Navigation Drawer Activity Vector Icons

我正在尝试自定义和着色 Android Studio 2.1.2 上的默认 Navigation Drawer Activity。我已经按照以下方式更改了 ic_menu_camera.xml 文件的颜色--

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportHeight="24.0"
    android:viewportWidth="24.0">
    <path
        android:fillColor="#f73a3a" //changed colour
        android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
    <path
        android:fillColor="#f73a3a" //changed colour
        android:pathData="M9,2L7.17,4H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2H9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" />
</vector>

预览中的颜色变化 window 如下图所示-

但是,应用程序启动时,颜色再次更改为默认 black/dark 灰色--

如何在此处实现更改后的颜色?

您需要在 onCreate

期间将 setItemIconTintList 设置为空
YourView.setItemIconTintList(null);

现在您可以直接编辑矢量资源并显示更改。