Skip to content

Instantly share code, notes, and snippets.

@danielgomezrico
Created April 1, 2016 13:37
Show Gist options
  • Save danielgomezrico/bffa2b216884e0a0d771eae27bcf7d18 to your computer and use it in GitHub Desktop.
Save danielgomezrico/bffa2b216884e0a0d771eae27bcf7d18 to your computer and use it in GitHub Desktop.
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment