1

I declared my menu items with android:showAsAction="ifRoom". My Activity is extending ActionBarActivity. In preview it is as expected but when run on my phone is it always in overflow.

From what I've seen nothing else is needed. My phone runs in Android 4.4.2 KitKat.

Am I missing anything else?

3
  • Please post your menu resource. Commented Feb 15, 2014 at 20:28
  • Could this be by design, because the phone screen is just to small? What happens if you use "always"? @CommonsWare is right, some more info would be useful. Commented Feb 15, 2014 at 20:28
  • @RolfSmit No, it's because aambrozkiewicz is using ActionBarCompat and you have to use a custom namespace, if you want to use attributes, that were introduced in newer versions. Commented Feb 15, 2014 at 20:33

2 Answers 2

3

You have to define your own namespace, if you want to use the showAsAction attribute with ActionBarCompat(I assume you are using ActionBarCompat because you mentioned, that you're extending ActionBarActivity):

xmlns:app="http://schemas.android.com/apk/res-auto"

and use showAsAction like this:

<item [...] app:showAsAction="always"></item>
Sign up to request clarification or add additional context in comments.

1 Comment

Great, thanks! I had that namespace but tried to use android:showAsAction.
0

Just try this...

<item android:id="@+id/action_blah"
    android:icon="@drawable/ic_c"
    android:title="@string/action_blah"
    app:showAsAction="(yourOptions)"/>

(yourOptions):

  1. always = To force to show on the actionbar.
  2. never = Not to show on your actionbar ever. and
  3. ifRoom = It will let your item if there is enough space on your action bar.

You can see these in Landscape mode.

HappyCoding

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.