How to remove/hide Title/Status bar from the android to make activity fullscreen using JAVA and Kotlin ?

If you want to hide the top title bar ( which is also called as Status bar ) which display battery status, network status, alerts etc while user is browsing your application. This can be done in two ways,

Hide by setting an activity theme in your app’s manifest file. Setting an activity theme in your app’s manifest file is the preferred approach if the status bar should always remain hidden in your app.

Modify your application AndroidManifest.xml as below,

<application
    ...
    android:theme="@android:style/Theme.Holo.NoActionBar.Fullscreen">
    ...
<application>

The advantages of using an activity theme are as follows:

  • It’s easier to maintain and less error-prone than setting a flag programmatically.
  • It results in smoother UI transitions, because the system has the information it needs to render your UI before instantiating your app’s main activity.

Programmatically Hide Title bar in Kotlin

import android.view.Window
import android.view.WindowManager

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        this.requestWindowFeature(Window.FEATURE_NO_TITLE);    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_layout_main)
}

}

As we can see in above code you will have to add following two lines and its associated imports in activities onCreate function,

this.requestWindowFeature(Window.FEATURE_NO_TITLE);    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

here, “this” refers to activity.

Programmatically Hide Title Bar in Java

For hiding title bar in JAVA, you have to add same code in onCreate of Activity in your android java code.

How to Remove Background from Photo... x
How to Remove Background from Photos on iOS & Android - PicsArt Tutorial

Leave a Comment

Sign up to our newsletter!

ADB Commands Android Android Applications Android Build system Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development, Debugging and Performance Tools Development and Build Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia NDK / Middleware / HAL Operating System Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web Design and Development Website Hosting Wordpress Yocto Embedded Linux