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?
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?
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:
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;
}
}
}
}
Please know that the hamburger menu is not shown on IOS builds.
© 2022 - 2024 — McMap. All rights reserved.