I would like to add a bottom border to the navigation bar in Xamarin Forms on Android.
On iOS I already wrote a custom renderer:
public class CustomNavigationBarRenderer : NavigationRenderer
{
private static readonly string ColorCode = "03d79e";
private static readonly Lazy<UIImage> BorderBottomLine = new Lazy<UIImage>(GetPixelImage);
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (Element == null)
return;
NavigationBar.ShadowImage = BorderBottomLine.Value;
}
private static UIImage GetPixelImage()
{
UIGraphics.BeginImageContext(new CGSize(1, 1));
CGContext context = UIGraphics.GetCurrentContext();
context.SetFillColor(Color.FromHex(ColorCode).ToCGColor());
context.FillRect(new CGRect(0, 0, 1, 1));
UIImage image = UIGraphics.GetImageFromCurrentImageContext();
UIGraphics.EndImageContext();
return image;
}
}
Unfortunately it's not that simple on Android, or at least I haven't figured it out yet.
Is there any simple way to implement a bottom border on the navigation bar?


