Remove title in Toolbar in appcompat-v7

AndroidAndroid ActionbarAndroid AppcompatAndroid Toolbar

Android Problem Overview


The documentation of Toolbar says

> If an app uses a logo image it should strongly consider omitting a title and subtitle.

What is the proper way to remove the title?

Android Solutions


Solution 1 - Android

getSupportActionBar().setDisplayShowTitleEnabled(false);

Solution 2 - Android

The correct way to hide/change the Toolbar Title is this:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);

This because when you call setSupportActionBar(toolbar);, then the getSupportActionBar() will be responsible of handling everything to the Action Bar, not the toolbar object.

See here

Solution 3 - Android

Try this...

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

    .....

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_landing_page);
	setSupportActionBar(toolbar);
	getSupportActionBar().setDisplayShowTitleEnabled(false);

    .....

 }

Solution 4 - Android

The reason for my answer on this is because the most upvoted answer itself failed to solve my problem. I have figured out this problem by doing this.

<activity android:name="NAME OF YOUR ACTIVITY"
    android:label="" />

Hope this will help others too.

Solution 5 - Android

Another way to remove the title from your Toolbar is to null it out like so:

Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
toolbar.setTitle(null);

Solution 6 - Android

this

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    //toolbar.setNavigationIcon(R.drawable.ic_toolbar);
    toolbar.setTitle("");
    toolbar.setSubtitle("");
    //toolbar.setLogo(R.drawable.ic_toolbar);

Solution 7 - Android

If you are using Toolbar try below code:

toolbar.setTitle("");

Solution 8 - Android

 Toolbar actionBar = (Toolbar)findViewById(R.id.toolbar);
    actionBar.addView(view);
    setSupportActionBar(actionBar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

take note of this line getSupportActionBar().setDisplayShowTitleEnabled(false);

Solution 9 - Android

You can use any one of bellow as both works same way: getSupportActionBar().setDisplayShowTitleEnabled(false); and getSupportActionBar().setTitle(null);

Where to use:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayShowTitleEnabled(false);

Or :

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 
    getSupportActionBar().setTitle(null);

Solution 10 - Android

Just add this attribute to your toolbar

app:title=" "

Solution 11 - Android

The correct way to hide title/label of ToolBar the following codes:

  Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(null);

Solution 12 - Android

I dont know whether this is the correct way or not but I have changed my style like this.

<style name="NoActionBarStyle" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowNoTitle">true</item>
</style>

Solution 13 - Android

Toolbar toolbar = findViewById(R.id.myToolbar);
    toolbar.setTitle("");

Solution 14 - Android

if your using default toolbar then you can add this line of code

Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false);

Solution 15 - Android

Nobody mentioned:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
    }

Solution 16 - Android

toolbar.setTitle(null);// remove the title

Solution 17 - Android

It's obvious, but the App Theme selection in design is just for display a draft during layout edition, is not related to real app looking in cell phone. In my case, there is no title bar in design but the title bar was always in cell phone.

I'm starting with Android programming and fight to discover a right solution.

Just change the manifest file (AndroidManifest.xml) is not enough because the style need to be predefined is styles.xml. Also is useless change the layout files.

All proposed solution in Java or Kotlin has failed for me. Some of them crash the app. And if one never (like me) intend to use the title bar in app, the static solution is cleaner.

For me the only solution that works in 2019 (Android Studio 3.4.1) is:

in styles.xml (under app/res/values) add the lines:

   <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

After in AndroidManifest.xml (under app/manifests)

Replace

android:theme="@style/AppTheme">

by

android:theme="@style/AppTheme.NoActionBar">

Solution 18 - Android

Just adding an empty string in the label of <application> (not <activity>) in AndroidMenifest.xmllike that -

<application
            android:label=""
            android:theme="@style/AppTheme">
            <activity
             .
             .
             .
             .
            </activity>
    </application>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiontimemanxView Question on Stackoverflow
Solution 1 - Androidmassaimara98View Answer on Stackoverflow
Solution 2 - AndroidDavid_EView Answer on Stackoverflow
Solution 3 - AndroidSilambarasan PoongutiView Answer on Stackoverflow
Solution 4 - AndroidChandra SekharView Answer on Stackoverflow
Solution 5 - AndroidMrEngineer13View Answer on Stackoverflow
Solution 6 - AndroidyounesView Answer on Stackoverflow
Solution 7 - Androidvarotariya vajsiView Answer on Stackoverflow
Solution 8 - AndroidsuulisinView Answer on Stackoverflow
Solution 9 - AndroidCrime_Master_GoGoView Answer on Stackoverflow
Solution 10 - AndroidDyno CrisView Answer on Stackoverflow
Solution 11 - AndroidHai RomView Answer on Stackoverflow
Solution 12 - AndroidGoudam mView Answer on Stackoverflow
Solution 13 - AndroidBacar PereiraView Answer on Stackoverflow
Solution 14 - AndroidKrishna Mohan SinghView Answer on Stackoverflow
Solution 15 - AndroidAndoctoreyView Answer on Stackoverflow
Solution 16 - Androiduser2167877View Answer on Stackoverflow
Solution 17 - AndroidPaulo BuchsbaumView Answer on Stackoverflow
Solution 18 - AndroidGk Mohammad EmonView Answer on Stackoverflow