I\'m trying to add a night theme for my app and I\'ve wasted nearly three hours just trying to make the text and icons in my navigation drawer turn white along with the dark
In my case, I needed to change the color of just one menu item - "Logout". I had to run a recursion and changed the title color:
NavigationView nvDrawer;
Menu menu = nvDrawer.getMenu();
for (int i = 0; i < menu.size(); i ++){
MenuItem menuItem = menu.getItem(i);
if (menuItem.getTitle().equals("Logout")){
SpannableString spanString = new SpannableString(menuItem.getTitle().toString());
spanString.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.red)), 0, spanString.length(), 0);
menuItem.setTitle(spanString);
}
}
I did this in the Activity's onCreate method.