How do you remove the title text from the Android ActionBar?

AndroidAndroid Actionbar

Android Problem Overview


I'm looking through the Holo.Light theme, and I can't seem to find the magic style to override to get rid of the title text that briefly shows up when my app first launches.

How can I do that?

Android Solutions


Solution 1 - Android

Try:

 getActionBar().setDisplayShowTitleEnabled(false);

For v.7:

 getSupportActionBar().setDisplayShowTitleEnabled(false);

Solution 2 - Android

I think this is the right answer:

<style name="AppTheme" parent="Theme.Sherlock.Light.DarkActionBar">
    <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
    <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
</style>

<style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
    <item name="android:displayOptions">showHome|useLogo</item>
    <item name="displayOptions">showHome|useLogo</item>
</style>

Solution 3 - Android

I'm very new to Android so correct me if I'm wrong, but I think if you decide to use navigation tabs on the Action Bar, they seemed to not be completely left aligned because the title text color is only transparent and hasn't gone away.

<style name="CustomActionBarStyle" parent="@android:style/Widget.Holo.ActionBar">
     <item name="android:displayOptions">useLogo|showHome</item>
</style>

worked for me.

Solution 4 - Android

Got it. You have to override

android:actionBarStyle

and then in your custom style you have to override

android:titleTextStyle

Here's a sample.

In my themes.xml:

<style name="CustomActionBar" parent="android:style/Theme.Holo.Light">
        <item name="android:actionBarStyle">@style/CustomActionBarStyle</item>
</style>

And in my styles.xml:

<style name="CustomActionBarStyle" parent="android:style/Widget.Holo.ActionBar">
    	<item name="android:titleTextStyle">@style/NoTitleText</item>
    	<item name="android:subtitleTextStyle">@style/NoTitleText</item>
</style>
    
<style name="NoTitleText">
    	<item name="android:textSize">0sp</item>
    	<item name="android:textColor">#00000000</item>
</style>

I'm not sure why setting the textSize to zero didn't do the trick (it shrunk the text, but didn't make it go away), but setting the textColor to transparent works.

Solution 5 - Android

In your Manifest

<activity android:name=".ActivityHere"
	 android:label="">

Solution 6 - Android

Write this statement under

setContentView(R.layout.activity_main);

getSupportActionBar().setDisplayShowTitleEnabled(false);

if extending AppCompactActivity use getSupportActionbar() if extending Activity use getActionBar() else it may give

null pointer exception

using android:label="" in AndroidManifest.xml for activity also works but your app won't appear in Recently used apps

Solution 7 - Android

you have two choice:

first:

getActionBar().setDisplayShowTitleEnabled(false);

If usign getActionBar() produced null pointer exception, you should use getSupportActionBar()

Second

getSupportActionBar().setTitle("your title");

or

getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().hide();

Solution 8 - Android

You can change the style applied to each activity, or if you only want to change the behavior for a specific activity, you can try this:

setDisplayOptions(int options, int mask) --- Set selected display 
  or
setDisplayOptions(int options) --- Set display options.

To display title on actionbar, set display options in onCreate()

getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);

To hide title on actionbar.

getSupportActionBar().setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

Details here.

Solution 9 - Android

i use this code in App manifest

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
		android:logo="@drawable/logo2"
        android:label="@string/title_text"
        android:theme="@style/Theme.Zinoostyle" >

my logo file is 200*800 pixel and use this code in main activity.java

getActionBar().setDisplayShowTitleEnabled(false);

it will work Corectly

Solution 10 - Android

I tried this. This will help -

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

getSupportActionBar should be called after setSupportActionBar, thus setting the toolbar, otherwise, NullpointerException because there is no toolbar set. Hope this helps

Solution 11 - Android

The only thing that really worked for me was to add:

<activity 
    android:name=".ActivityHere"
    android:label=""
>

Solution 12 - Android

getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().hide();

hope this will help

Solution 13 - Android

If you only want to do it for one activity and perhaps even dynamically, you can also use

ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(actionBar.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE);

Solution 14 - Android

Use the following:

requestWindowFeature(Window.FEATURE_NO_TITLE);

Solution 15 - Android

as a workaround just add this line incase you have custom action/toolbars

this.setTitle("");

in your Activity

Solution 16 - Android

While all of these are acceptable, if your activity only contains a main activity, you can edit res\values\styles.xml like so:

<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>

I've updated parent and added the .NoActionBar property to the Light theme from Android Studios Create Blank Application Wizard.

Solution 17 - Android

Simply extends your java file from AppCompatActivity and do this:

ActionBar actionBar = getSupportActionBar(); // support.v7
actionBar.setTitle(" ");

Solution 18 - Android

In your manifest.xml page you can give address to your activity label. the address is somewhere in your values/strings.xml . then you can change the value of the tag in xml file to null.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="title_main_activity"></string>
</resources>

Solution 19 - Android

I am new to Android so maybe I am wrong...but to solve this problem cant we just go to the manifest and remove the activity label

<activity
        android:name=".Bcft"
        android:screenOrientation="portrait"
        
        **android:label="" >**

Worked for me....

Solution 20 - Android

ActionBar actionBar = getActionBar();
actionBar.setTitle("");

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
QuestionChristopher PerryView Question on Stackoverflow
Solution 1 - AndroidFilippo MazzaView Answer on Stackoverflow
Solution 2 - AndroidcesardsView Answer on Stackoverflow
Solution 3 - AndroidsparknoobView Answer on Stackoverflow
Solution 4 - AndroidChristopher PerryView Answer on Stackoverflow
Solution 5 - AndroideasycheeseView Answer on Stackoverflow
Solution 6 - AndroidManoharView Answer on Stackoverflow
Solution 7 - AndroidHamidView Answer on Stackoverflow
Solution 8 - AndroidSiqi LiuView Answer on Stackoverflow
Solution 9 - AndroidMilaaaadView Answer on Stackoverflow
Solution 10 - Androidvoucher_wolvesView Answer on Stackoverflow
Solution 11 - AndroidShiftlessAndreasView Answer on Stackoverflow
Solution 12 - AndroidMeshPadukkaView Answer on Stackoverflow
Solution 13 - AndroidHeiko RuppView Answer on Stackoverflow
Solution 14 - AndroidVivekView Answer on Stackoverflow
Solution 15 - AndroidVaygethView Answer on Stackoverflow
Solution 16 - Androideyoung100View Answer on Stackoverflow
Solution 17 - AndroidHarsh PrajapatiView Answer on Stackoverflow
Solution 18 - AndroidDamoonView Answer on Stackoverflow
Solution 19 - AndroidEbin Xavier JoseView Answer on Stackoverflow
Solution 20 - AndroidJoe LewisView Answer on Stackoverflow