Actionbar not shown with AppCompat

The question:

I am backporting my app to API7 with AppCompat and have a problem with the actionbar.

When I use FragmentActivity the actionbar is shown on my phone (API18), but with ActionBarActivity it shows up as the optionmenu by pressing the menubutton.

On the emulator with API7 the actionbar is always shown as an optionsmenu.

Any ideas?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Use the compat name space for your menu items like this:

<menu xmlns:android=""
  xmlns:compat="" >
    <item android:id="@+id/action_whatever"
      compat:showAsAction="ifRoom"  />

Method 2

Related to a duplicate that points to this post, I was having trouble making my buttons appear as action items instead of overflow items, despite having showAsAction set to always. I managed to coerce it by extending my activity with Activity instead of ActionBarActivity. According to this answer, this is acceptable if you don’t need to support api levels below 11.

...extends ActionBarActivity:

extends ActionBarActivity

...extends Activity:

enter image description here

Method 3

I do debug with Doogee Valencia Y100Pro, and menu as “three little square” not visible, but when I extended my MainActivity with, then I obtain text/icon menu in action bar. Next screenshot and menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="" xmlns:app="">
    <item android:id="@+id/action_settings"

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment