caipivara
4/1/2016 - 1:37 PM

Android - set status bar color programmatically (just for > lollipop)

Android - set status bar color programmatically (just for > lollipop)

public void setStatusBarColor(@ColorRes int statusBarColor) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    int color = ContextCompat.getColor(this, statusBarColor);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.setStatusBarColor(color);
  }
}