Skip to content

Instantly share code, notes, and snippets.

@suryaviyyapu
Created September 7, 2020 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suryaviyyapu/7f89e33450677c9ba5475bcd908e57ec to your computer and use it in GitHub Desktop.
Save suryaviyyapu/7f89e33450677c9ba5475bcd908e57ec to your computer and use it in GitHub Desktop.
Android: Set custom colors on status bar.
//Implement outside the onCreate method
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setStatusBarGradiant(Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(ContextCompat.getColor(activity, R.color.colorPrimaryDark)); //Change colorPrimaryDark to customize
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment