0

Despite there being enough space in the action bar , only the icon is being displayed, even when I am using

app:showAsAction= "always|withText" 

Full code:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.ishaan.admin.notify.Profile">
    <item android:id="@+id/action_logout"
        android:title="Logout"

        android:icon="@drawable/logout_icon"
        app:showAsAction= "always|withText"  />
</menu>
Isj
  • 2,020
  • 1
  • 14
  • 20

2 Answers2

1

It is known thing on the Android 4.0 and discussed ealier

Your can find solution here: android 4.0, text on the action bar NEVER shows

Community
  • 1
  • 1
Ilya Tretyakov
  • 6,848
  • 3
  • 28
  • 45
1
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/toolbar_right_button"
        android:orderInCategory="1"
        android:title="Text"
        app:actionLayout="@layout/menu_item_1"
        app:showAsAction="ifRoom|withText"/>
</menu>

and in Layout create Layout File menu_item_1.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <Button
        android:id="@+id/logout_button"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableRight="@drawable/ic_toolbar_locked"
        android:gravity="center_vertical"
        android:text="Text"
        android:textColor="@color/PrimaryColour"/>
</RelativeLayout>
leema
  • 61
  • 1
  • 8