1
votes

I have a menu item, with icon and text. I am using Appcompat v7 library. The menu item is not displaying text, even when showAsAction is set to withText|always or vice-versa.

menu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_next"
        android:icon="@drawable/ic_action_registration_next"
        android:orderInCategory="0"
        android:title="Next"
        app:showAsAction="always" />
</menu>

I have tried these combinations for showAsAction.

always|withText
withText|always
ifRoom|withText

The toolbar only shows the icon, but not the title. How can i show both title and icon? Please look at the image below:

enter image description here

Let me know if you need anything else.

1
I believe it's either text or icon with a menu xml. If you want both, you need a custom layout in the toolbarOneCricketeer
@cricket_007, thanks for the info.Vamsi Challa

1 Answers

1
votes

Action bar/toolbar implementations consider withText to be a request, not a command. They will decide whether to show the text on whether or not there is sufficient room for it. In this case, appcompat-v7 apparently thinks that there is not enough room. If you try rotating this device to landscape, or testing on a tablet, you should see the title show up, if you have withText as part of your app:showAsAction attribute.