Android: compat: showAsAction = "always | withText" does not work

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:compat="http://schemas.android.com/apk/res-auto" >
    <item android:id="@+id/action_chat"
        android:icon="@drawable/ico_enter_chat"
        android:title="Enter Chat"
        compat:showAsAction="always|withText" />

    <item android:id="@+id/action_map"
        android:icon="@drawable/ico_map"
        android:title="Users Map"
        compat:showAsAction="always"    />
    <item android:id="@+id/action_logout"
        android:icon="@drawable/ico_log_out"
        android:title="Log Out"
        compat:showAsAction="always"  />



</menu>

Here is my XML menu file, theoretically it should display two icons as separate icons and the first icon with a title.

However, in the application, it does not display the title, here is the screenshot: enter image description here

So why doesn't it display "title"?

+4
source share
4 answers

Source: http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems

If your menu item supplies both a title and an icon with attributes for the title and icon, then the action element displays only the icon by default.

If you want to display the title of the text, add "withText" to the showAsAction attribute.

. "withText" , . , , , , .

+2
+2

It worked for me

app:showAsAction="ifRoom|withText"
0
source

appcompat_v7> values> config.xml

<bool name="abc_config_allowActionMenuItemTextWithIcon">false</bool>

change

<bool name="abc_config_allowActionMenuItemTextWithIcon">true</bool>
0
source

Source: https://habr.com/ru/post/1569880/


All Articles