0

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;
}
Dog Lover
  • 618
  • 1
  • 6
  • 18

2 Answers2

2

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

Community
  • 1
  • 1
Abhishek
  • 2,350
  • 2
  • 21
  • 35
0

setDisplayShowHomeEnabled(boolean) is what you're after.

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

Chris Horner
  • 1,994
  • 2
  • 16
  • 26