Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS Causes content to go below navigation bars

Using the following code causes my layout to extend below the navigation bars. Id just like to change the status bar color without messing up the layout.

int currentapiVersion = android.os.Build.VERSION.SDK_INT;
        if (currentapiVersion >= android.os.Build.VERSION_CODES.LOLLIPOP){
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            getWindow().setStatusBarColor(this.getResources().getColor(R.color.statusbar_color));
            //TRANSPARENT FOR TESTING
            getWindow().setNavigationBarColor(this.getResources().getColor(android.R.color.transparent));
        }

I feel like I'm missing something...

enter image description here

like image 796
Derek Avatar asked Nov 16 '14 21:11

Derek


1 Answers

Just add

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                |  View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

It worked for me.

like image 108
GoodnessJesus Avatar answered Oct 17 '22 12:10

GoodnessJesus