xamarin inflate menu action bar icons not showing, only text appears

1.8k Views Asked by At

i use this code to create menu for action bar in xamarin. but text is being shown, not the icon. i want icons only to be appear. Here is what i try for creating the menu.

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/android-auto">
<item android:id="@+id/action_reply"
    android:icon="@drawable/ic_rotate"
    android:title="Reply"
    android:showAsAction="always" />
<item android:id="@+id/action_undo"
    android:icon="@drawable/ic_dashboard"
    android:title="Undo"
    android:showAsAction="never" />
</menu>

Here is the action bar code

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FEFEFE">
<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    android:layout_alignParentTop="true" />

can anyone suggest some improvements?

1

There are 1 best solutions below

0
On

You are using the Android Support V7 Toolbar, you need to correct your menu to use xmlns:local="http://schemas.android.com/apk/res/android-auto" instead of xmlns:app="http://schemas.android.com/apk/res/android-auto" then change android:showAsAction="always" to local:showAsAction="always"