2015-06-22 108 views
1

我使用此代码为xamarin中的操作栏创建菜单。但正在显示文字,而不是图标。我只想出现图标。这是我尝试创建菜单。xamarin充气菜单操作栏图标不显示,只显示文本

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

这里是行动条码

<?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" /> 

任何人都可以提出一些改进?

+0

我也得到这个问题,总是得到的菜单图标,而不是图标。你找到解决方案吗? – Carl

+0

同样的问题,有什么进展? – cfl

+0

@Charl我发现我的解决方案与此答案:http://stackoverflow.com/questions/25744146/action-bar-icon-not-showing-in-android-action-bar/25744230#25744230 – cfl

回答

0

您使用的是Android的支持V7工具栏,你需要纠正你使用菜单中的xmlns:local="http://schemas.android.com/apk/res/android-auto"代替xmlns:app="http://schemas.android.com/apk/res/android-auto"然后更改android:showAsAction="always"local:showAsAction="always"