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.
Asked
Active
Viewed 2,047 times
1 Answers
1
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);

Rediska
- 1,392
- 10
- 14
-
Or is there any possibility to refer to a color of the selected theme? – Ananas1232 Jan 02 '16 at 14:42
-
Thnaks, but i found a very simple way. [link]http://stackoverflow.com/questions/8630694/theme-dependent-colors-of-selected-widgets – Ananas1232 Jan 02 '16 at 16:41