我使用此代码在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" />有没有人能提出一些改进的建议?
发布于 2017-10-13 10:51:58
您正在使用安卓支持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"
https://stackoverflow.com/questions/30972769
复制相似问题