Home » Android » Android – How to remove app name from ActionBar

Android – How to remove app name from ActionBar

Posted by: admin June 15, 2020 Leave a comment

Questions:

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>
How to&Answers:
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);

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

Answer:

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

Answer:

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){}

Answer:

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

bar.setDisplayShowTitleEnabled(false);
bar.setDisplayShowHomeEnabled(false);

Answer:

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");