Intro

In this post we will demonstrate how to add color images as icons in your navigation drawer menu in Android. If you need help creating a navigation drawer you can check out this POST.

Exercise

First we will create a new android project using empty activity and add a navigation drawer. Kotlin is our language of choice in this project. In the navigation drawer we will add five items: Home, Profile, Settings, About and Exit. We will add icons to all of this items using png images.

These are the pictures we will be using:

Next we will initialize our navigation drawer menu in MainActivity. The code looks like this:

The default style of the icons in your is tinted, so when we start our app, the navigation drawer will look like this:

The color in our icons is gone. But luckily we can solve this with a single line of code. To remove the tint, in our initNavigationDrawer() method we will add this line of code:

And now this is how our navigation drawer looks like:

As a bonus tip we will change the color of the burger icon because black does not look good on the background. So in the initNavigationDrawer() method we will add this line of code:

And the final look is ready:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

You can find the whole project here: https://github.com/AleksandarGulevski/Navigation_Drawer_Color_Images

Happy coding!

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *