Narala Mounika
Narala Mounika

Reputation: 1

Remove Icon from ActionBar

Is there a way to hide the app icon from the ActionBar; that is, have an ActionBar without an icon?

Here is my current code:

 public boolean onCreateOptionsMenu(Menu menu) {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setBackgroundDrawable(
            new ColorDrawable(Color.parseColor("#000000")));
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(" OrderIn");
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setIcon(R.drawable.actionbar_logo);

    return true;
}

Upvotes: 0

Views: 317

Answers (2)

Chris Horner
Chris Horner

Reputation: 2004

setDisplayShowHomeEnabled(boolean) is what you're after.

https://developer.android.com/reference/android/support/v7/app/ActionBar.html#setDisplayShowHomeEnabled(boolean)

Upvotes: 0

Abhishek
Abhishek

Reputation: 2370

If you've defined android:logo="..." in the tag of your AndroidManifest.xml, then you need to use this stuff to hide the icon:

pre-v11 theme

<item name="logo">@android:color/transparent</item>

v11 and up theme

<item name="android:logo">@android:color/transparent</item>

The use of these two styles has properly hidden the action bar icon on a 2.3 and a 4.4 device for me (this app uses AppCompat).

Upvotes: 2

Related Questions