Reputation: 105
I have made simple navigation pages. Now I want to add icon for android in navigation bar.
I added an screenshot and highlighted with black circle where i want to add an icon.
I also tried custom renderer.
That is provided answer from this post: Change icon on Navigation bar - Xamarin.Forms Android
But not worked for me.
Here it is
Upvotes: 0
Views: 6918
Reputation: 101
Thank you Dilmah.
It work for me. With Xamarin.Forms 2.5, I change the constructor by
public CustomMapRender(Context context) : base(context)
to avoid warning of obsolete constructor.
Upvotes: 0
Reputation: 1127
[assembly: ExportRenderer(typeof(NavigationPage), typeof(CustomMapRenderer))]
namespace XamarinFormsMaps.Droid
{
public class CustomMapRenderer : NavigationPageRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
{
base.OnElementChanged(e);
var bar = (Android.Support.V7.Widget.Toolbar)typeof(NavigationPageRenderer)
.GetField("_toolbar", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(this);
bar.SetLogo(Resource.Drawable.icon);
}
}
}
Try this one!
Upvotes: 3