简体   繁体   中英

Xamarin Forms toolbar not showing on Android

I have a ContentPage that is accessed via a TabPage's child, it is simply accessed via a click of a button. On iOS, the page has a toolbar

iOS工具栏

However on Android, there isn't one displayed. I have to rely on the user to use the back button on their device.

How can I get this to display on Android? I have tried using several fixes including: NavigationPage.SetHasNavigationBar(this, true); but this makes no difference.

To enable hierarchical navigation from a tab you just need to wrap those tabs in a NavigationPage, like so:

public partial class TabPage : TabbedPage
{
    Page TabOne;
    Page TabTwo;
    Page TabThree;

    public TabPage()
    {
        TabOne = new NavigationPage(new TabOnePage());
        TabTwo = new NavigationPage(new TabTwoPage());
        TabThree = new NavigationPage(new TabThreePage());

        Children.Add(homePage);
        Children.Add(resourcesPage);
        Children.Add(helpPage);
    }
}

Hope that helps.

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