I'd like to build a navigation drawer where each item has a different selection color (the icon tint and text color) as the google play store has:
I'm not sure how they've solved this, I think they use different activities with different drawers. I want to use fragments and I want to change the icon tint and text color. Any ideas how I can do this? I'm using google's design support library and a drawer layout with a navigation view in there.
There's a simpler option for the lazy ones out there.
TL;DR: Just create a new
style
with thecolorPrimary
being your desired color and then set theNavigationView
'stheme
to be this newstyle
.Just make a new
style
as:This
style
will automatically inherit from your basetheme
(on my case it wasAppTheme.NoActionBar
) and then you just have to set thecolorPrimary
with your desired color.Then you just have to set the
NavigationView
'stheme
as:in:
use
app:itemIconTint
in yourNavigationView
for icons and useapp:itemTextColor
for textColorsSample :
drawable/navigation_text_color
:and
layout
:If by dynamically you mean programmatically you could try this:
So you could define multiple colors for different settings like Day or Night.
Adding to what @DAVOOD said. The below color selector worked for me.
Finllay i got the answer,
You must change the colorAccent in the colors file to which ever color you want :
This solution worked for me