Reputation: 11
I've got a slight problem with colors in Android. I'm writing an app with a navigation drawer, so far so good. I know how to change the themes, so now the color of the toolbar and items changes, and this works fine. However, how do I programmatically change the color of the header of the navigation drawer? I can't find anything about it on Google.
Upvotes: 1
Views: 2053
Reputation: 1470
Add navigation header at run time:
View view = new View(context);
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
view.setBackgroundColor(someColor);
navigationView.addHeaderView(view);
Upvotes: 1