I have a fairly straightforward menu that I am showing in an Activity, but some of the menu items have text that is too long to fit on screen. The default behavior for menus appears to be ellipsizing the text, as shown below.
Menu XML that I'm inflating in onCreateOptionsMenu()
:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_too_long"
android:title="This text is a tad too long"
android:icon="@drawable/ic_glass_logo"/>
</menu>
Is it possible to get the menu item text to adjust its size or wrap to a second line when it is too long? In other words, I would like menus inflated from XML to behave more like CardBuilder.Layout TEXT
.
I would like to avoid creating my own menu and continue using Glass's built-in menu APIs.
Changing the formatting of the menu labels is not possible through public APIs. From a UX point of view, menu labels longer than two or three words seems undesirable. Consider that if you enable voice menus in your application, those commands should be brief that the user can speak them conveniently.
If the length of your menu text is because there is supplemental information that you can separate from the "action" that the menu performs, consider using MenuUtils.setDescription
to move the supplemental information into the footer of the menu item, which can hold more content. You can call this method from within onCreateOptionsMenu
or onPrepareOptionsMenu
.