12

This is my app:

enter image description here

Now i want to remove the app name from my ActionBar...
I want it like this:

enter image description here

my code:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:myapp="http://schemas.android.com/apk/res-auto" >

    <item
        android:id="@+id/phone"
        android:title="@string/phone"
        android:icon="@drawable/phone"
        myapp:showAsAction="ifRoom" />

    <item
        android:id="@+id/computer"
        android:title="@string/computer"
        android:icon="@drawable/computer"
        myapp:showAsAction="ifRoom"  />


</menu>
Lugarini
  • 792
  • 5
  • 11
  • 32

7 Answers7

24
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);

Or you can just call actionbar.setTitle("")

vincentzhou
  • 710
  • 6
  • 18
  • setTitle("") makes the title under launcher icon empty too. So the first strategy is better. – SHB Feb 03 '19 at 06:08
4

If you want to hide it use this code

getSupportActionBar().setDisplayShowTitleEnabled(false)

or if you want to change the name use this

getSupportActionBar().setTitle("type yor title here");
Alex
  • 81
  • 7
4

I've seen some questions about the location etc. Here is the complete solution. Use this in onCreate();

    setContentView(R.layout.activity_main);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    // Set title to false AFTER toolbar has been set
    try
    {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }
    catch (NullPointerException e){}
John T
  • 814
  • 10
  • 17
2

Call setDisplayShowHomeEnabled() and setDisplayShowTitleEnabled() on ActionBar, which you get via a call to getActionBar().

adsion
  • 187
  • 3
  • 13
2

For Android 4.2.1 edit the default theme NoActionnBar and add this code in MainActivity.java file

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (getSupportActionBar() != null) {
        getSupportActionBar().hide();
    }
}
1

You could try setTitle(""). If you are using ActionBar or ToolBar, then call bar.setTitle("") or :

bar.setDisplayShowTitleEnabled(false);
bar.setDisplayShowHomeEnabled(false);
SilentKnight
  • 13,761
  • 19
  • 49
  • 78
0

Just write this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
    WindowManager.LayoutParams.FLAG_FULLSCREEN);

    getSupportActionBar().hide();

    setContentView(R.layout.activity_main);
}
m4n0
  • 29,823
  • 27
  • 76
  • 89