We are going to learn how to remove the title bar ( titlebar ) and the notification bar ( notificationbar ) in our Android application.
The title bar shows the title that our Android application has as we have defined it in the AndroidManifest.xml. The notification bar has the time, battery status, internet / gps connections, and notifications of calendars, messages, etc:
There are several ways to do it: for the entire application or for each activity. We see each case:
-
- In general (for the entire application)
If we want that in a single line of code we remove any of the bars (title or notification) for the entire application, we must add in the AndroidManifest.xml, inside the application tag, the android code: theme seen below:1two34<!-- Theme.NoTitlebar quita el titulo-->
<
application
android:icon
=
"@drawable/icon"
android:label
=
"@string/app_name"
android:theme
=
"@android:style/Theme.NoTitleBar"
>
or
1two34<!-- añadiendo Fullscreen quita titulo y notificacion-->
<
application
android:icon
=
"@drawable/icon"
android:label
=
"@string/app_name"
android:theme
=
"@android:style/Theme.NoTitleBar.Fullscreen"
>
- For each Activity in particular
If what we want is to remove bars according to what suits us in each screen (activity), we can do it by adding in the java code of each activity, inside the onCreate method , the following:1two//Quitamos barra de titulo de la aplicacion
this
.requestWindowFeature(Window.FEATURE_NO_TITLE);
or
1two//Quitamos barra de notificaciones
this
.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
- In general (for the entire application)