Hide Status Bar in Android

To hide status bar in Android using Kotlin, we can request that the visibility of the status bar or other screen/window decorations be changed by setting window.decorView.systemUiVisibility with View.SYSTEM_UI_FLAG_FULLSCREEN in the Activity Kotlin file.

Let us create an Android Application and write code to hide the status bar in Activity kotlin file.

Add the following line to our MainActivity.kt file.

</>
Copy
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN

MainActivity.kt

</>
Copy
package com.example.myapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_FULLSCREEN
    }
}

Run this Android Application, and you should observe that the status bar is being hidden, as shown in the following screenshot.

Hide Status Bar in Android

The complete code for this Android project can be downloaded at the following link.

Download Android Project – Hide Status Bar

Conclusion

In this Kotlin Android Tutorial, we learned how to hide status bar in Android Application programmatically.