How to remove title text from Android ActionBar?

I am looking at the Holo.Light theme and I can’t find a magical style to override to get rid of the title text that briefly appears when my application starts for the first time.

How can i do this?

+98
android android-actionbar
Oct 05 2018-11-11T00:
source share
20 answers

Got it. You have to override

 android:actionBarStyle 

and then in your custom style you need to override

 android:titleTextStyle 

Here is an example.

In my theme.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 textSize to zero didn’t do this trick (it squeezed the text but didn’t make it go away), but setting the transparency of textColor works.

+41
Oct 05 2018-11-11T00:
source share

Try:

  getActionBar().setDisplayShowTitleEnabled(false); 

For v.7:

  getSupportActionBar().setDisplayShowTitleEnabled(false); 
+201
Jul 14 2018-12-18T00:
source share

I think this is the correct 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> 
+93
Jan 14
source share

I'm very new to Android, so correct me if I'm wrong, but I think that if you decide to use the navigation tabs in the action bar, they don't seem to be fully aligned because the title text color will only be transparent and not gone .

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

worked for me.

+63
Jul 12 '12 at 22:50
source share

In your manifest

 <activity android:name=".ActivityHere" android:label=""> 
+20
Mar 30 '12 at 3:19
source share

Record this statement in

 setContentView(R.layout.activity_main); getSupportActionBar().setDisplayShowTitleEnabled(false); 

if the extension AppCompactActivity uses getSupportActionbar() , if the extension is used to use getActionBar() otherwise it can give

 null pointer exception 

using android:label="" in AndroidManifest.xml for activity also works, but your application will not appear in Recently used apps

+12
Jun 20 '16 at 10:01
source share

You have two options:

the first:

 getActionBar().setDisplayShowTitleEnabled(false); 

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

Second

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

or

 getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().hide(); 
+7
Sep 29 '16 at 14:19
source share

I use this code in the 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 is 200 * 800 pixels and use this code in main activity.java

 getActionBar().setDisplayShowTitleEnabled(false); 

he will work corectly

+6
May 25 '15 at 14:36
source share

You can change the style that applies to each action, or if you want to change the behavior for a specific action, you can try the following:

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

To display the title in the action bar, set the display options to onCreate ()

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

To hide the title in the action bar.

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

More details here .

+5
Aug 14 '14 at 10:32
source share

I have tried this. It will help -

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

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

+5
Sep 05 '17 at 11:28
source share
 getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().hide(); 

hope this helps

+3
Jul 09 '16 at 17:28
source share

Use the following:

 requestWindowFeature(Window.FEATURE_NO_TITLE); 
+2
Oct 05 2018-11-11T00:
source share

If you want to do this for just one action, and perhaps even dynamically, you can also use

 ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(actionBar.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE); 
+2
Mar 30 '13 at 22:01
source share

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

 <activity android:name=".ActivityHere" android:label="" > 
+2
Apr 04 '14 at 23:46
source share

as a workaround, just add this line if you have custom actions / toolbars

 this.setTitle(""); 

in your activity

+1
Jan 20 '16 at 7:45
source share

Although all of them are acceptable, if your activity contains only the main action, you can edit res\values\styles.xml as follows:

 <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 updated parent and added the .NoActionBar property to the Light theme from the Android Studios Create Blank Application wizard.

+1
Jun 04 '16 at 4:42 on
source share

Just extends your Java file from AppCompatActivity and does this:

 ActionBar actionBar = getSupportActionBar(); // support.v7 actionBar.setTitle(" "); 
+1
Feb 05 '18 at 10:05
source share

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

 <?xml version="1.0" encoding="utf-8"?> <resources> <string name="title_main_activity"></string> </resources> 
0
Mar 23 '15 at 9:42
source share

I am new to Android, so maybe I'm wrong ... but to solve this problem we can’t just go to the manifest and remove the activity shortcut

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

Worked for me ....

0
Jun 09 '15 at 4:57
source share
 ActionBar actionBar = getActionBar(); actionBar.setTitle(""); 
-3
Feb 08 '13 at 11:17
source share



All Articles