title: How to change status bar color of AppCompatDialogFragment in Android 11 (API level 30)
body: <p>I want to change the color of status bar to match the toolbar. I have try as many as possible code from other answers, and still not working. This code is working in Android 10, but not in Android 11. The code below provide me with a translucent status bar:</p>
  <pre class="lang-kotlin prettyprint-override"><code>
  class SettingDialog : AppCompatDialogFragment() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          dialog?.window?.requestFeature(Window.FEATURE_NO_TITLE)
      }
  
      override fun onResume() {
          super.onResume()
          dialog?.window?.apply {
              setLayout(MATCH_PARENT, MATCH_PARENT)
              setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
              addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
              clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS) //This flag is deprecated
              statusBarColor = ContextCompat.getColor(context, R.color.primary_dark)
              val insetController = ViewCompat.getWindowInsetsController(decorView)
              insetController?.isAppearanceLightStatusBars = true
          }
      }
  
      override fun onCreateView(
          inflater: LayoutInflater,
          container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View {
          val v = inflater.inflate(R.layout.dialog_setting, container, false)
          ...
          return v
      }
  
  }
  </code></pre>
  <p>What i got:
  <a href="https://i.stack.imgur.com/tXscX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tXscX.jpg" alt="Status bar color has a translucent color" /></a></p>
  <p>What i want:
  <a href="https://i.stack.imgur.com/UQZKF.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UQZKF.jpg" alt="Status bar color has the same color as toolbar" /></a></p>