3

I'm using ActionBarCompat and have an options menu defined in XML. It looks like this:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/createNew"
        app:showAsAction="always|withText"
        android:icon="@drawable/ic_action_new"
        android:title="@string/createNew" />
</menu>

The icon appears in the actionbar, but without text! How can I get the text showing? What did I do wrong?

Thank you in advance!

Aron Lorincz
  • 1,677
  • 3
  • 19
  • 29
  • 2
    What else do you have in your action bar (tabs? list nav? custom view?)? Can you post a screenshot? – CommonsWare May 28 '14 at 13:03
  • 1
    Is there any other elements present actionbar.One more thing to tell use of "always" is not good practice. Always use "ifroom". – Ramesh_D May 28 '14 at 13:05
  • Yes, I know that ifRoom is better, but it doesn't work either. There's nothing in my ActionBar, just the defaults: an icon, title, and the button I mentioned. There's a huge amount of room on the left of it! However when I rotate the device to landscape orientation, it displays correctly. – Aron Lorincz May 28 '14 at 19:53
  • I've also tried to use both "android:" and "app:" namespace prefix for showAsAction parameter, but it's still displayed without text :( Any idea? – Aron Lorincz May 29 '14 at 09:12
  • @ÁronLőrincz, did you find the solution ?. I am stuck with the same problem. – SimpleCoder May 24 '16 at 09:09
  • Unortunately, I didn't. But prefer the new Toolbar instead of the obsolete ActionBar. – Aron Lorincz May 25 '16 at 12:57

1 Answers1

0

Your code is working fine here. I have tested it, the only problem might be the device screen size.

Try to test it on landscape mode or big screen device.

Aman Singh
  • 370
  • 1
  • 9