简体   繁体   English

Xamarin.forms工具栏Android

[英]Xamarin.forms toolbar 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. 我目前正在测试android平台上的工具栏。 Below is what it currently looks like. 以下是当前的外观。

图片

Is there a way to have the toolbaritems display right below the navigation bar? 有没有办法让工具栏项目显示在导航栏的正下方?

In Xamarin.Forms , you could use ToolbarItem to implement this feature. Xamarin.Forms ,可以使用ToolbarItem来实现此功能。

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

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

Effect : 效果:

在此处输入图片说明

If you want display ToolbarItem right below the navigation back button, 如果您想在导航后退按钮的正下方显示ToolbarItem

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

Effect : 效果:

在此处输入图片说明

Remember to wrap your Modal in a NavigationPage , as the ToolbarItems otherwise will not appear. 请记住将您的模态包装在NavigationPage中 ,否则ToolbarItems不会出现。 For more information, you could refer to the article and this question . 有关更多信息,请参阅本文和此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM