How to remove title bar in android studio app with example

In this tutorial, we will find how to remove the title bar in android. We also talk about different ways to achieve it. Hide the title bar means to display the content into fullscreen. That Title Bar In android Called Action bar. There are Many Available Themes in Android studio for No Title bar. You can use them either on just one activity or on the Whole App.

Before proceeding further, create an android studio project if you didn’t create yet.

Remove the title bar in android.

Remove the title bar or we can say an action bar is achieved in some ways.

  • We can change the theme attribute into the manifest.xml file.
  • Adding some code into the java file.
  • By changing some content into the style.xml file.

1. Java code for Hiding the title bar in android

The requestWindowFeature(Window.FEATURE_NO_TITLE) method of Activity must be called to hide the title.

Note:  It must be added before the setContentView method.

call the public method of ActionBar class i.e getSupportActionBar() and it will return the instance of ActionBar class.  Using that instance u can call the hide() method. After calling the hide method it will remove the title bar from the activity.

For example :

package com.codingquery.hidetitlebar;

import android.os.Bundle;
import android.view.Window;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);   //hide the title
        setContentView(R.layout.activity_main);
        getSupportActionBar().hide();   //hide the Title bar
        
    }
}

2. Remove the ActionBar in Android studio using the android_manifest.xml file.

You can use the NoActionBar theme in a particular Activity. Add the theme attribute in Activity.

For example :

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.codingquery.hidetitlebar">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"> //NoActionBar theme applying here.
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

MainActivity.java

package com.codingquery.hidetitlebar;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

3. Delete the title bar from the whole Application

If you want to achieve this just edit your theme in style.xml file. Change the current theme DarkActionBar into NoActionBar. It will remove the title bar from the whole Application. The resulted android application will be Action Bar free.

res/values/Style.xml file

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>
</resources>

Output:

remove title bar in android app

If you like this tutorial, How to remove an action bar in the android studio. Follow us on Facebook and Telegram. For more information comment below.

You may also like...

Leave a Reply

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