I have a custom Entry for my Xamarin.Forms Android app. Currently, I'm using a Custom Renderer to give the Entry an oval shape with a border.
I also want to change the color of the Entry Border on focus and revert back to the original color on unfocus.
My custom Renderer is below:
public class EntryCellRenderer : EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
var UIEntry = (e.NewElement != null) ? (EntryCell)e.NewElement : (EntryCell)e.OldElement;
if (this.Control != null)
{
Control.Gravity = Android.Views.GravityFlags.CenterVertical;
Control.SetPadding(30, 30, 30, 31);
GradientDrawable gd = new GradientDrawable();
gd.SetShape(ShapeType.Rectangle);
var BackgroundColor = ColorHelper.FromHex(CoreTheme.COLOR_DEFAULT_CLEAR);
var ColorRef = Android.Graphics.Color.Argb(
(byte)(BackgroundColor.A * 255),
(byte)(BackgroundColor.R * 255),
(byte)(BackgroundColor.G * 255),
(byte)(BackgroundColor.B * 255));
gd.SetColor((int)ColorRef);
UIEntry.BackgroundColor = Xamarin.Forms.Color.Transparent;
gd.SetStroke(7, Android.Graphics.Color.LightGray);
gd.SetCornerRadius(20.0f);
Control.SetBackground(gd);
}
}
}
I'm not sure how to proceed with having a focus event for what I want to do above with this custom Entry.