如何更改辅助工具栏项 Xamarin Forms 的图标 [英] How to change icon of Secondary Toolbaritem Xamarin Forms

查看:30
本文介绍了如何更改辅助工具栏项 Xamarin Forms 的图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将自定义图标设置为 ContentPage 上的辅助"订单 Toolbaritem,但该图标每次都在 Android 上呈现为 3 点/点状列表图标(避风港没有部署到 iOS,没有理由怀疑它有什么不同).

I am trying to set a custom icon to a "Secondary" Order Toolbaritem on a ContentPage, but the icon is rendered as the 3-dot /dotted-list icon on Android every time (haven't deployed to iOS, no reason to suspect it's any different).

我的代码很简单

<Toolbaritem Order="Secondary"
Icon="img.png"/>

我想保留Toolbaritem的下拉列表功能.

I want to keep the drop-down list function of the Toolbaritem.

推荐答案

那个三点状图标(Kebab 菜单图标)是一个菜单图标.Order="Secondary" 将工具栏项移动到次要表面,在 Android 上,次要表面是烤肉串菜单.和 微软文档 关于次表面上的工具栏项目是这样说的:

That 3-dot icon (Kebab menu icon) is a menu icon. Order="Secondary" moves toolbar item to secondary surface, on Android that secondary surface is kebab menu. And microsoft docs have this to say about toolbar items on secondary surface:

将 Order 属性设置为 Secondary 的 ToolbarItem 对象中的图标行为在各个平台上不一致.避免对出现在二级菜单中的项目设置 IconImageSource 属性.

Icon behavior in ToolbarItem objects that have their Order property set to Secondary is inconsistent across platforms. Avoid setting the IconImageSource property on items that appear in the secondary menu.

在 Android 上,项目放置在烤肉串菜单中,不显示图标,而在 iOS 上,次要项目放置在主工具栏下方,并显示图标.我不确定 UWP,我目前没有办法测试它.如果您想要在所有平台上使用一致的图标外观,您将必须实现自己的工具栏.

On Android items are placed in kebab menu and icons are not displayed, while on iOS secondary items are placed just below main toolbar and icons are displayed. I'm not sure about UWP, I currently do not have a way to test it. If what you want is consistent look with icons across all platforms you will have to implement your own toolbar.

Xamarin.Forms git 问题要求正是该功能.问题似乎很旧但它仍然打开并且仍然有一些活动,所以也许有一天可以将图标添加到 android 上的辅助 ToolbarItem.与此同时,他们建议使用 解决方法 - 使用主要的 ToolbarItem 带有Kebab 菜单"徽标,单击该徽标时会切换自定义 ListView 菜单上的 IsVisible 属性,该菜单位于您的菜单应位于的位置 RelativeLayout.

This Xamarin.Forms git issue asks for exactly that functionality. Issue seems old but it's still open and there's still some activity, so maybe someday it will be possible to add icons to secondary ToolbarItem on android. In the meantime, they suggest a workaround - use primary ToolbarItem with "Kebab menu" logo which when clicked toggles IsVisible property on custom ListView menu positioned with RelativeLayout where your menu should be.

这篇关于如何更改辅助工具栏项 Xamarin Forms 的图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆