title: What's the best way to set the color of the status bar to a gradient drawable?
body: <p>So right now I have a bunch of activities and fragments that have the following code in <code>onCreate</code> or <code>onViewCreated</code>:</p>
  <pre><code>val window = this.window
  val background = ResourcesCompat.getDrawable(this.resources, R.drawable.background_color, null)
  window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
  window.statusBarColor = ContextCompat.getColor(applicationContext, android.R.color.transparent)
  window.setBackgroundDrawable(background)
  </code></pre>
  <p>This sets the status bar to a drawable with a gradient color. The problem with this is that I don't like having to copy and paste this code into every activity and fragment I have. Not only that, this doesn't work for my <code>SplashActivity</code> which is the first activity that gets launched when the user runs the app for the first time. So what's the best way to set the status bar color to a custom gradient color and a way that also works for the first activity that gets launched?</p>