Home » Android » Android Applications » How to Hide Title and Status Bar in Android: Fullscreen Mode in Java & Kotlin

How to Hide Title and Status Bar in Android: Fullscreen Mode in Java & Kotlin

When developing Android applications, there are times when you want to make the activity run in fullscreen mode, removing the title or status bar for a clean, immersive user experience. This post will guide you through removing the title and status bar using Java and Kotlin.

Remove Title and Status Bar in Android

Android provides simple ways to hide both the title and status bar for any activity. This is particularly useful for apps like games, media players, or any app that requires full-screen space.

1. Removing the Title Bar

The title bar is often the action bar of an Android app. To remove it, you can do so from the onCreate() method of your activity, or modify it in your app’s theme.

In Java:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE); // Removes title bar
    setContentView(R.layout.activity_main);
}
In Kotlin:
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    requestWindowFeature(Window.FEATURE_NO_TITLE) // Removes title bar
    setContentView(R.layout.activity_main)
}

2. Hiding the Status Bar

The status bar at the top of the screen shows the battery, time, and network status. You can hide this in fullscreen mode to give users a more immersive experience.

In Java:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                         WindowManager.LayoutParams.FLAG_FULLSCREEN); // Hides status bar
    setContentView(R.layout.activity_main);
}
In Kotlin:
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    requestWindowFeature(Window.FEATURE_NO_TITLE)
    window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
                    WindowManager.LayoutParams.FLAG_FULLSCREEN) // Hides status bar
    setContentView(R.layout.activity_main)
}

3. Modifying Themes to Hide Title and Status Bar

You can also hide the title bar and status bar at the theme level by modifying your styles.xml file. This makes it easier to apply fullscreen mode across multiple activities without needing to modify each one individually.

In res/values/styles.xml:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowFullscreen">true</item>
</style>

This approach removes the action bar and status bar across all activities where this theme is applied.

Final Thoughts

Hiding the title and status bar in Android creates a clean, immersive experience for users. Whether you use Java or Kotlin, both languages allow you to easily manipulate the visibility of these UI elements. Use the above methods to improve your app’s visual appeal and provide users with a distraction-free experience.


Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment