简体   繁体   中英

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

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>

Effect :

在此处输入图片说明

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>

Effect :

在此处输入图片说明

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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