Change hamburger menu icon - Xamarin.Forms Android & UWP
For UWP part, you could replace hamburg icon easily. Because in UWP platform, it was render with the button with PaneButton
style, And you could find it here. Just copy it to UWP App.xaml file and replace the content property like the following.
<Application.Resources>
<ResourceDictionary>
<Style x:Key="PaneButton" TargetType="Button">
<Setter Property="FontFamily" Value="{ThemeResource SymbolThemeFontFamily}" />
<Setter Property="FontSize" Value="20" />
<Setter Property="Height" Value="48" />
<Setter Property="Width" Value="48" />
<Setter Property="Content" Value="" />
</Style>
</ResourceDictionary>
</Application.Resources>
For Android part, we need custom MasterDetailPageRenderer
render like the following
[assembly: ExportRenderer(typeof(MainPage), typeof(IconNavigationPageRenderer))]
namespace masterDe.Droid
{
public class IconNavigationPageRenderer : MasterDetailPageRenderer
{
public IconNavigationPageRenderer(Context context):base(context) { }
private static Android.Support.V7.Widget.Toolbar GetToolbar() => (CrossCurrentActivity.Current?.Activity as MainActivity)?.FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
protected override void OnLayout(bool changed, int l, int t, int r, int b)
{
base.OnLayout(changed, l, t, r, b);
var toolbar = GetToolbar();
if (toolbar != null)
{
for (var i = 0; i < toolbar.ChildCount; i++)
{
var imageButton = toolbar.GetChildAt(i) as Android.Widget.ImageButton;
var drawerArrow = imageButton?.Drawable as DrawerArrowDrawable;
if (drawerArrow == null)
continue;
// replace default hamburg icon
imageButton.SetImageDrawable(Forms.Context.GetDrawable(Resource.Drawable.icon));
}
}
}
}
}
Icon="hmenu.png"
in the<MasterDetailPage>
opening tag but it didn't do anything – SendETHToThisAddress