Ananas1232
Ananas1232

Reputation: 11

Android Navigation drawer Header color change

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

Answers (1)

Rediska
Rediska

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

Related Questions