Can't set StatusBar color with setStatusBarColor if FLAG_LAYOUT_NO_LIMITS is used

Viewed 279

I'm trying to draw a layout behind the NavigationBar. To do this I set FLAG_LAYOUT_NO_LIMITS as follows:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

This indeed causes the layout to be drawn behind the NavigationBar, but it also sets the StatusBar background color to white/transparent. Changing the StatusBar color using getWindow().setStatusBarColor(Color.RED); has no effect.

I'm all the work dynamically and can't use and styling .xml files. Is this a known behavior of FLAG_LAYOUT_NO_LIMITS?

1 Answers

getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

Also check this

Related