Introduction

This article explains how to hide the Title Bar on Android. Android Studio is used to create the sample.
TitleBar
The Title Bar contains the title of your application that you can set depending on your requirements. You can also hide the Title Bar using the Android manifest.xml file and also through coding.
Hide Title Bar using Java code
First, we will see how to hide the Title Bar using Java code. To do that you need to call the requestWindowFeature(Window.FEATURE_NO_TITLE) method of an Activity. But you need to call this before the setContentView( ) method of an Activity.
  1. @Override
  2. protected void onCreate(Bundle savedInstanceState)
  3. {
  4. super.onCreate(savedInstanceState);
  5. requestWindowFeature(Window.FEATURE_NO_TITLE);
  6. setContentView(R.layout.activity_main);
  7. }
  8. }
Hide Title Bar using Android Manifest.xml file
To hide the Title Bar using the Android Manifest.xml file you need to set the Android theme to NoTitleBar like this:
  1. android:theme="@android:style/Theme.NoTitleBar">
Android Manifest.xml file
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.hidetitlebar"
  4. android:versionCode="1"
  5. android:versionName="1.0" >
  6. <uses-sdk
  7. android:minSdkVersion="7"
  8. android:targetSdkVersion="16" />
  9. <application
  10. android:allowBackup="true"
  11. android:icon="@drawable/ic_launcher"
  12. android:label="@string/app_name"
  13. android:theme="@style/AppTheme" >
  14. <activity
  15. android:name="com.hidetitlebar.MainActivity"
  16. android:label="@string/app_name"
  17. android:theme="@android:style/Theme.NoTitleBar">
  18. <intent-filter>
  19. <action android:name="android.intent.action.MAIN" />
  20. <category android:name="android.intent.category.LAUNCHER" />
  21. </intent-filter>
  22. </activity>
  23. </application>
  24. </manifest>
Step 1
Create a project like this:
hidetitlebarproject
Step 2
Create an XML file with the following:
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:paddingBottom="@dimen/activity_vertical_margin"
  6. android:paddingLeft="@dimen/activity_horizontal_margin"
  7. android:paddingRight="@dimen/activity_horizontal_margin"
  8. android:paddingTop="@dimen/activity_vertical_margin"
  9. tools:context=".MainActivity"
  10. android:background="#d155">
  11. <TextView
  12. android:layout_width="wrap_content"
  13. android:layout_height="wrap_content"
  14. android:text="Hide Title Bar"
  15. android:textSize="40dp"
  16. android:layout_centerInParent="true"/>
  17. </RelativeLayout>
Step 3
Create a Java class file with the following.
In this, you will hide the Title Bar by calling the requestWindowFeature(Window.FEATURE_NO_TITLE) method of an Activity. But you need to call this before the setContentView( ) method of an Activity.
  1. package com.hidetitlebar;
  2. import android.os.Bundle;
  3. import android.app.Activity;
  4. import android.view.Menu;
  5. import android.view.Window;
  6. import android.view.WindowManager;
  7. public class MainActivity extends Activity {
  8. @Override
  9. protected void onCreate(Bundle savedInstanceState) {
  10. super.onCreate(savedInstanceState);
  11. requestWindowFeature(Window.FEATURE_NO_TITLE);
  12. // WindowManager.LayoutParams.FLAG_FULLSCREEN);//int flag, int mask
  13. setContentView(R.layout.activity_main);
  14. }
  15. }
Step 4
Android Manifest.xml file
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.hidetitlebar"
  4. android:versionCode="1"
  5. android:versionName="1.0" >
  6. <uses-sdk
  7. android:minSdkVersion="7"
  8. android:targetSdkVersion="16" />
  9. <application
  10. android:allowBackup="true"
  11. android:icon="@drawable/ic_launcher"
  12. android:label="@string/app_name"
  13. android:theme="@style/AppTheme" >
  14. <activity
  15. android:name="com.hidetitlebar.MainActivity"
  16. android:label="@string/app_name"
  17. >
  18. <intent-filter>
  19. <action android:name="android.intent.action.MAIN" />
  20. <category android:name="android.intent.category.LAUNCHER" />
  21. </intent-filter>
  22. </activity>
  23. </application>
  24. </manifest>
Step 5
hidetitlebar