Xamarin.Forms Hamburger Menu Icon gone after Update to Xamarin.Forms 2.2
Asked Answered
S

3

9

After I updated my Xamarin.Forms project from Xamarin.Forms 2.0 to Xamarin.Forms 2.2, the Hamburger Icon is gone.

I've googled without luck, has anybody experienced the same issue?

Soever answered 29/4, 2016 at 8:41 Comment(0)
B
7

If the default icon has disappeared you can set your own icon of the Master page for example:

public class MasterPage : MasterDetailPage
{
    FlyOutMenuPage menu = new FlyOutMenuPage ();
    Master = menu;
}

public class FlyOutMenuPage : ContentPage
{
    Icon = "menu.png";
} 

And menu.png is a resource image, you can get lots of icon from here:

https://www.iconfinder.com/search/?q=hamburger&price=free

Blissful answered 29/4, 2016 at 14:49 Comment(3)
Thanks for the tip. I have some pictures in the app, that already work on buttons. I set one of these as the icon of the masterdetailpage, but the MasterButton (Hamburger) is still not available. ;( May this a bug, that only appears in Win10 UWP apps?Soever
I would like to add that there's lot talk against tge hamburger menu as an design pattern that lowers user engagement. So consider othe navigation patterns as well (such as toolbar, tabs or menu links)Fanti
It is recommended to use a 32x32 icon. You can find one here: freeicons.io/office-and-workstation-icons-5/menu-icon-18931#Unbreathed
A
0

Mine was hidden in Android, so I had to write a custom renderer to apply a color and set the opacity to show it again:

[assembly: ExportRenderer(typeof(CustomNavigationPage), typeof(CustomNavigationRenderer))]

namespace App.Droid
{
    public class CustomNavigationRenderer : NavigationPageRenderer
    {

        public CustomNavigationRenderer(Context context) : base(context)
        {
        }

        protected override void OnLayout(bool changed, int l, int t, int r, int b)
        {
            base.OnLayout(changed, l, t, r, b);
            var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            for (var i = 0; i < toolbar.ChildCount; i++)
            {
                var imageButton = toolbar.GetChildAt(i) as ImageButton;

                var hamburger = imageButton?.Drawable as DrawerArrowDrawable;
                if (hamburger == null)
                    continue;

                hamburger.Color = Context.GetColor(Resource.Color.primary_text_default_material_light);
                hamburger.Alpha = 255;
            }


        }
    }
}
Annabelle answered 31/8, 2018 at 13:53 Comment(0)
L
0

Please know that the hamburger menu is not shown on IOS builds.

Lidia answered 9/9, 2020 at 10:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.