Home > Enterprise >  what is the correct way to change the app status bar white and status bar black in color in android?
what is the correct way to change the app status bar white and status bar black in color in android?

Time:10-19

Change my app status bar color to white and status bar icon color to black

if (Build.VERSION.SDK_INT >= 21) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        getWindow().setStatusBarColor(Color.WHITE);
    }

Since, setSystemUiVisibility() is Deprecated and my minSdk version is 21 and targetSdk version is 31

How to achieve this?

Thanks in advance

CodePudding user response:

You can change the status bar color using the Window class added in API level 21

window.setStatusBarColor(ContextCompat.getColor(activity,R.color.my_statusbar_color))
  • Related