How to change the colour of the navigation drawer item

How to change the colour of the navigation drawer item

change navigation drawer icon color
navigation drawer menu item title color in android
android navigation drawer selected item background color
how to change navigation drawer icon in android studio
custom navigation drawer in android
android navigation drawer change selected item background color
how to change navigation item text color in android
android navigation drawer highlight selected item

I want to change my navigation drawer list item's background colour to be changed when i click on it. Also it should change the text and icon colour of that item as well. Thanks in advance..


This is quite simple and is similar to changing the background of any view that you use. You can simply create a method and write all the change code into it. Pass the view as a parameter in the method.

Whenever you click on any of the navigation drawer items, pass your view on the method.

For instance, check this method

private boolean viewSelected(View view) {
    ViewHolder currentViewHolder = (ViewHolder) view.getTag();
    KTextView yourtextView = currentViewHolder.yourtextView;
    view.setBackgroundColor(ResourceUtil.getInstance().getColor(R.color.colorSideMenuSelectedBackground));
    currentViewHolder.viewSelector.setVisibility(View.VISIBLE);
    yourtextView.setTypeface(yourtextView.getContext(), ResourceUtil.getInstance().getString(R.string.yourFontName));

    if (lastSelectedView == null) {
        lastSelectedView = view;
        return true;
    }
    if (lastSelectedView != view) {
        ViewHolder oldViewHolder = (ViewHolder) lastSelectedView.getTag();
        oldViewHolder.viewSelector.setVisibility(View.GONE);
        lastSelectedView.setBackgroundColor(ResourceUtil.getInstance().getColor(android.R.color.white));
        KTextView newTextView = oldViewHolder.yourtextView;
        newTextView.setTypeface(yourtextView.getContext(), ResourceUtil.getInstance().getString(R.string.yourfontname));
        lastSelectedView = view;
        return true;
    }
    return false;
}

This method will simply change the background, font and color of the views.

Hope this helps!

How to Customize the Navigation Bar Icons on Android Oreo, How do I change the selected item color in navigation drawer? In this android programming source code example, we are going to change the color of navigation drawer indicator icon in android. You can copy and adopt this source code example to your android project without reinventing the wheel. Below is a step by step source code to change the color of navigation drawer indicator icon in android. activity_main.xml.


This can be done using https://developer.android.com/guide/topics/resources/color-list-resource.

Create two drawable files : 1.drawer_background

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="checked_background_color" android:state_checked="true" />
<item android:color="default_background_color" />
</selector>

2.drawer_text_background

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="checked_text_color" android:state_checked="true" />
<item android:color="default_text_color" />
</selector>

And add these two properties to your NavigationView ie

app:itemIconTint="@drawable/drawer_background"
app:itemTextColor="@color/drawer_text_background"

one more if some color is overlapping with some other color

  app:itemBackground="@android:color/transparent"

Now, All you have to do is to set an item as checked on Click listener of that item to change background and text color. You can do it programmatically.

How do I change the navigation icon on my Android? I was working on Nav drawer on my app. I have made the background of my nav drawer #000000(Black). Whenever I select any item the textcolor of text changes from #E44F50(Carrot Red) to black but I cant change the background color of the selected item. All I want is to change the background color of selected Item from black to carrot red.


I solved it setting this attribute to my NavigationView app:itemBackground="@drawable/drawer_selector"

and my drawer_selector is as below

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/white" />
<item android:state_focused="true" android:drawable="@color/white" />
<item android:state_activated="true" android:drawable="@color/white" />
<item android:drawable="@color/orange" />

How do I change the color of the hamburger icon on my Android toolbar? Correct, when I used the default implementation of the navigation drawer via Android Studio, the currently active fragment's title on the navigation drawer is highlighted blue and I would like to change that blue to be a color I use for my app and also make the font bold but only for the selected item.


This video shows how to design/ customize ( changing icons, text, icon color, text color Duration: 13:36 Posted: Mar 7, 2018 How to change Drawer selected menu item background color in Flutter In this Google flutter code example we are going to learn how to change Drawer selected menu item background color in Flutter. You can copy and adopt this source code example to your Flutter project without reinventing the wheel.


Learn how to create a Navigation Drawer Activity in Android Studio in the Simplest way and how Duration: 2:19 Posted: Apr 6, 2019 How can I change Background Color of the drawer? I don't need to change drawer items need to change the background color of the drawer fully. By default, it's white while I need to make it Green.


Changing text color of menu item in navigation drawer. I'm trying to add a night theme for my app and I've wasted nearly three hours just trying to make the text  how to change vector asset and image color in android navigation drawer. how to change vector asset and image color in android navigation drawer. Skip navigation 5 mins to create icon color or