Xamarin.forms工具栏Android [英] Xamarin.forms toolbar Android

查看:154
本文介绍了Xamarin.forms工具栏Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以使工具栏项目显示在导航栏的正下方?我还注意到,当我单击工具栏上的按钮以导航到新页面时,该工具栏会浮动到手机屏幕的左上角,然后消失.我不确定为什么会这样做,我宁愿让它立即消失.我目前正在测试android平台上的工具栏.下面是它的当前外观.

Is there a way to have the toolbaritems display right below the navigation bar? I also noticed that when I click a button within my toolbar to navigate to a new page the toolbar floats to the topleft corner of my phones screen and then disappears. I'm not sure why it does that and I would much rather have it simply disappear right away. I'm currently testing the toolbar on the android platform. Below is what it currently looks like.

推荐答案

有没有一种方法可以使工具栏项目显示在导航栏的正下方?

Is there a way to have the toolbaritems display right below the navigation bar?

Xamarin.Forms中,您可以使用 ToolbarItem 来实现此功能.

In Xamarin.Forms , you could use ToolbarItem to implement this feature.

如果要在右上角显示ToolbarItem,请将ToolBarItemorder设置为Secondary,以将选项强制进入Android的溢出菜单:

If you want display ToolbarItem at the right corner, set the order of the ToolBarItem to Secondary to force the option into an overflow menu on Android :

<ContentPage.ToolbarItems>
    <ToolbarItem Text="Share" Activated="EditClicked_Share" Order="Secondary" />
    <ToolbarItem Text="Create" Activated="EditClicked_Create" Order="Secondary" />
</ContentPage.ToolbarItems>

效果:

如果要在导航后退按钮的正下方显示ToolbarItem

If you want display ToolbarItem right below the navigation back button,

<ContentPage.ToolbarItems>
    <ToolbarItem Text="Share" Activated="EditClicked_Share"  Order="Primary" Priority="0" />
    <ToolbarItem Text="Create" Activated="EditClicked_Create"  Order="Primary" Priority="1" />
    <ToolbarItem Text="Save" Activated="EditClicked_Save"  Order="Primary" Priority="2" Icon="ic_action_content_save.png" />
</ContentPage.ToolbarItems>

效果:

记住要将模态包装在NavigationPage中,否则将不会出现ToolbarItems.有关更多信息,您可以参考文章和此

Remember to wrap your Modal in a NavigationPage, as the ToolbarItems otherwise will not appear. For more information, you could refer to the article and this question.

这篇关于Xamarin.forms工具栏Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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