Skip to content

Instantly share code, notes, and snippets.

@dimanem
Created December 13, 2017 09:01
Show Gist options
  • Save dimanem/722c39768f6bb4bcded9cfd98bab10d2 to your computer and use it in GitHub Desktop.
Save dimanem/722c39768f6bb4bcded9cfd98bab10d2 to your computer and use it in GitHub Desktop.
Set Status Bar Color programatially
private void setStatusBarColor(int color) {
if (color == Color.TRANSPARENT) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
getWindow().setStatusBarColor(color);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment