You need to programmatically change the color of the status bar in Lollipop. I use the following code:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(getResources().getColor(R.color.status_bar_color)); window.setNavigationBarColor(Color.BLUE); } 

The color changes, but the window size changes as well. As a result, the buttons located below crawl over the navigation bar. If you remove the flag FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS , the color does not change. How can I change the color of the status bar without changing the window size?

    2 answers 2

    Write your style and override colorPrimaryDark in it
    Where necessary, this style to apply

    Details are described here: https://developer.android.com/training/material/theme.html

    • Inherited the theme of the application from Theme.Material.Light and redefined in the styles colorPrimaryDark. The problem is exactly the same: the color changes normally, but at the same time the window creeps in height. More and padding on the sides appeared. How to make sure that the window does not spread out in height? - BArtWell
    • In the code, you don’t change anything, just by style, right? I can find out what you are testing? - Eugene Krivenja
    • Yes, just style. I test on different devices, Samsung S4, Nexus 5, emulators - built-in and Genymotion. - BArtWell
    • I have a Nexus 5 c 5.1.1, always changing the color of the article, I have never come across a similar one as you describe. I have no more ideas, see the code, somewhere there is something wrong. - Eugene Krivenja

    It turns out that such a glitch may occur due to the SlidingMenu library. There indents are set manually and the size of the navigation bar is not taken into account on the Lollipop. The solution can be found here .