Background Color extends past Border Custom Entry Renderer

jboydajboyda USMember

I created a simple custom entry renderer to add rounded corners and border color. However, when I set the background color of the custom entry, the fills the entire rectangular box, extending past the rounded corners. This only happens on Android.

Here is the Android renderer:

protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || e.NewElement == null)
                return;

            try
            {
                element = (EntryBox)this.Element;

                GradientDrawable gradientDrawable = new GradientDrawable();
                gradientDrawable.SetShape(ShapeType.Rectangle);
                gradientDrawable.SetColor(element.BackgroundColor.ToAndroid());
                gradientDrawable.SetStroke(4, element.BorderColor.ToAndroid());
                gradientDrawable.SetCornerRadius(DpToPixels(Context, (float)element.CornerRadius));

                Control.SetBackground(gradientDrawable);
                Control.SetPadding(
                    (int)DpToPixels(this.Context, Convert.ToSingle(12)), Control.PaddingTop,
                    (int)DpToPixels(this.Context, Convert.ToSingle(12)), Control.PaddingBottom);


            } catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }

Any help would be appreciated.

Sign In or Register to comment.