Why Make an App Fullscreen?
When you are dealing with portable devices you are usually dealing with limited screen real estate. This means that you have less room to display information to the user, and if your app chooses not to hide the title bar and notification bar you are left with even less space.
Personally, I think the title bar is kind of plain looking and generally not necessary. Usually you know what app you are currently using, and there isn't much space to make the title bar display anything interesting.
|Screenshot of an Android App with Title Bar and Notification Bar|
Hiding the Title Bar Programatically
Use the following code to hide the title bar programatically.
// Hide the title bar requestWindowFeature(Window.FEATURE_NO_TITLE);
Hiding the Notification Bar Programatically
Use the following code to hide the notification bar programatically.
// Go full screen final Window window = getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
The first parameter to the setFlags function is the set of flags you would like to set and the second parameter is a filter. By passing in FLAG_FULLSCREEN filter, we are saying this is the only flag we would like to update.
Don't Forget the Imports
To use the preceding code, you need to make the following imports.
import android.view.Window; import android.view.WindowManager;
Warning: Go Fullscreen Before Calling setContentView
If you don't call the code to go fullscreen before calling setContentView you will run into errors.
|Screenshot of the logcat output showing the error|
And Now Your App is Fullscreen
Below is a screenshot of the app running in fullscreen mode.
|Android App Running in Fullscreen Mode|