public static void UpdateBackground(BorderView touchView, global::Android.Views.View view) { var borderWidth = touchView.BorderWidth; var context = view.Context; GradientDrawable strokeDrawable = null; if (0 < borderWidth) { strokeDrawable = new GradientDrawable(); strokeDrawable.SetColor(touchView.BackgroundColor.ToAndroid()); strokeDrawable.SetStroke((int)context.ToPixels(borderWidth), touchView.BorderColor.ToAndroid()); strokeDrawable.SetCornerRadius(context.ToPixels(touchView.CornerRadius)); } var backgroundDrawable = new GradientDrawable(); backgroundDrawable.SetColor(touchView.BackgroundColor.ToAndroid()); backgroundDrawable.SetCornerRadius(context.ToPixels(touchView.CornerRadius)); if (null != strokeDrawable) { var ld = new LayerDrawable(new Drawable[] { strokeDrawable, backgroundDrawable }); ld.SetLayerInset( 1, (int)context.ToPixels(borderWidth), (int)context.ToPixels(borderWidth), (int)context.ToPixels(borderWidth), (int)context.ToPixels(borderWidth) ); //view.SetBackgroundDrawable(ld); view.Background = ld; } else { //view.SetBackgroundDrawable(backgroundDrawable); view.Background = backgroundDrawable; } view.SetPadding( (int)context.ToPixels(borderWidth + touchView.Padding.Left), (int)context.ToPixels(borderWidth + touchView.Padding.Top), (int)context.ToPixels(borderWidth + touchView.Padding.Right), (int)context.ToPixels(borderWidth + touchView.Padding.Bottom) ); }