Isj
Isj

Reputation: 2070

Action Bar not displaying menu item with both icon and text

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>

Upvotes: 0

Views: 1538

Answers (2)

leema
leema

Reputation: 61

<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>

Upvotes: 1

Ilya Tretyakov
Ilya Tretyakov

Reputation: 7010

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

Upvotes: 1

Related Questions