Can't change navigation drawer icon color in android

2015-07-20 android navigation-drawer

OK, I know this is a trivial issue but for some reason it isn't working for me. I have done a lot of things suggested in other answers but in vain. My drawable folder has white color icons. I even tried to change it from styles.xml but that doesn't work either. I am testing it on my Lollipop device. Any help will be appreciated. Thanks in advance.

This is a portion of my manifest file.

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_drawer"
        android:label="@string/app_name" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version"
            tools:replace="android:value" />

        <activity
            android:name=".Activity_Splash"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
                android:name=".Activity_test"
                android:launchMode="singleInstance"
                android:theme="@style/AppTheme.Base"
                android:windowSoftInputMode="stateHidden" />

And finally this is my style.xml. Similar is for v-21.

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowContentTransitions">true</item>
        <item name="android:windowAllowEnterTransitionOverlap">true</item>
        <item name="android:windowAllowReturnTransitionOverlap">true</item>
        <item name="android:actionMenuTextColor">#fff</item>
        <item name="colorPrimary">@color/ColorPrimary</item>
        <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
        <item name="drawerArrowStyle">@style/MyDrawerArrowToggle</item>
        <item name="windowActionBar">false</item>
        <item name="colorAccent">#fff</item>
        <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
        <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
</style>

Answers

You should use ThemeOverlay.AppCompat.Dark.ActionBar as your toolbar style. It sets colorControlNormal to android:textColorPrimary, which is white for dark themes. And it doesn't change other attrs from main style.

<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto" >
    ... 
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
</android.support.v7.widget.Toolbar>

Also remove drawerArrowStyle from your main style, it's not needed.

If you are using the Design support library, you can modify the icon colours using the app:itemIconTint property:

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    android:fitsSystemWindows="true"
    android:theme="@style/AppTheme"
    app:headerLayout="@layout/nav_header_main"
    app:itemIconTint="#f00"
    app:itemTextColor="#0f0"
    app:menu="@menu/nav_drawer" />

As a bonus, above also shows how to change the colour of the text with app:itemTextColor.

Related