Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup windowDrawsSystemBarBackgrounds programmatically?

I want to add the attribute windowDrawsSystemBarBackgrounds programmatically, or in code, instead of the values-v21, because I only need it in 1 activity, and I'm using a theme selector in my app, so I can't have multiple themes.

Is possible to enable this attribute in the code? If so, then how can I do it?

Thanks in advance.

like image 915
Jahir Fiquitiva Avatar asked Jul 26 '15 03:07

Jahir Fiquitiva


1 Answers

I found the answer:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(getResources().getColor(android.R.color.transparent));
        }
like image 187
Jahir Fiquitiva Avatar answered Oct 22 '22 16:10

Jahir Fiquitiva