Navigation drawer item icon not showing original colour
No more grey! Keep the original icon colours in your navigation drawer by setting the icon tint to null. Implement this in the XML or directly in your Java code:
XML:
Java:
With this change, your app's icons retain their original splendour, dodging the Android system's typical grey influencer look.
Taking control: Custom icon colours and states
Unleashing the power of colour state lists
To orchestrate specific colours for different item states, deploy a colour state list. You can do this by generating an XML file in the res/color/
directory. Here's a small demo:
You can apply this colour state list to your drawer items either through code execution or via XML styling.
Dynamic icon colour changes: Meet setColorFilter
For swift and saucy icon tinting during runtime, get acquainted with setColorFilter
:
Remember, mutating the icon is a must-do when you alter drawable properties - it's like making sure your changes don't wake up the sleeping clone army of the drawable.
Don't lose your style: Aesthetics matter
A cohesive and visually appealing navigation drawer works wonders for your app's charm. Maintaining icon's original hues is like dressing them in your brand's uniform - it creates a consistent, aesthetically pleasing user experience.
XML Icon uniformity: Matching the suit and tie
Plan for all of your icons to align with a uniform hue for that sleek, minimalistic look? Achieve this bliss in your navigation drawer menu XML file:
This snazzy tweak sets all icons to a dashing white when they're chilling (unselected). When coupled with a colour state list, you can differentiate between them based on their 'busy' or 'idle' states.
Was this article helpful?