Ted
Ted

Reputation: 33

Make color of icon in navigation drawer

I'm trying to learn Android, and I'm attempting to make a navigation drawer.

My goal is to achieve something like this:

Goal

But my result looks like this:

Result

This is my style.xml:

    </style>

    <style name="Base.AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/md_deep_purple_500</item>
        <item name="colorPrimaryDark">@color/md_deep_purple_700</item>
        <item name="colorAccent">@color/md_white_1000_50</item>
    </style>

    <style name="ToolbarTheme" parent="AppTheme">
        <item name="android:textColorPrimary">@android:color/white</item>
        <item name="android:textColorSecondary">@android:color/white</item>
    </style>

    <style name="NavigationViewTheme" parent="AppTheme">
        <item name="textAppearanceListItem">@style/TextAppearance.AppCompat.Body2</item>
        <item name="android:icon">@style/Theme.AppCompat.Light</item>
    </style>
</resources>

This is my navigation_drawer_header:

<?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="16dp"
        android:gravity="bottom"
        android:theme="@style/ThemeOverlay.AppCompat.Light"
        >
</FrameLayout>

Can anyone suggest to me how these should be corrected?

Upvotes: 3

Views: 1179

Answers (1)

Jithin Sunny
Jithin Sunny

Reputation: 3402

This is because the NavigationView add tint to the icons. To avoid this you can add

navigationView.setItemIconTintList(null);

You can add color state list. Get a look into this

Upvotes: 6

Related Questions