How to remove title bar or notification bar, title bar and notification bar

 

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:

Title bars and notifications

There are several ways to do it: for the entire application or for each activity. We see each case:

    1. 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:

      1
      two
      3
      4
      <!-- Theme.NoTitlebar quita el titulo-->
      <application android:icon="@drawable/icon"
      android:label="@string/app_name"
      android:theme="@android:style/Theme.NoTitleBar">

      or

      1
      two
      3
      4
      <!-- añadiendo Fullscreen quita titulo y notificacion-->
      <application android:icon="@drawable/icon"
      android:label="@string/app_name"
      android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
    2. 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:

      1
      two
      //Quitamos barra de titulo de la aplicacion
      this.requestWindowFeature(Window.FEATURE_NO_TITLE);

      or

      1
      two
      //Quitamos barra de notificaciones
      this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *