0

How can I convert this code to Kotlin?

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
setContentView(R.layout.activity_login)

When I tried, the following warning appeared:

setter for systemUiVisibility: Int' is deprecated. Deprecated in Java 'SYSTEM_UI_FLAG_LIGHT_STATUS_BAR: Int' is deprecated. Deprecated in Java

Richie Bendall
  • 7,738
  • 4
  • 38
  • 58
Fabio Ramos
  • 33
  • 2
  • 8

1 Answers1

5

Include dependency androidx.core:core-ktx:1.5.0-alpha05

Then:

WindowCompat.getInsetsController(window, window.decorView)?.apply {
    isAppearanceLightStatusBars = true
}
veritas1
  • 8,740
  • 6
  • 27
  • 37