diff --git a/Xamarin.Forms.Platform.Android/Material/MaterialButtonRenderer.cs b/Xamarin.Forms.Platform.Android/Material/MaterialButtonRenderer.cs index 7fae306e63c..cdd7d36f45d 100644 --- a/Xamarin.Forms.Platform.Android/Material/MaterialButtonRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Material/MaterialButtonRenderer.cs @@ -55,7 +55,8 @@ public MaterialButtonRenderer(Context context) _automationPropertiesProvider = new AutomationPropertiesProvider(this); _buttonLayoutManager = new ButtonLayoutManager(this, alignIconWithText: true, - borderAdjustsPadding: true); + preserveInitialPadding: true, + borderAdjustsPadding: false); SoundEffectsEnabled = false; SetOnClickListener(this); @@ -240,7 +241,7 @@ void UpdateBorder() if (borderColor.IsDefault) StrokeColor = _defaultBorderColor; else - base.StrokeColor = new ColorStateList(new[] { new int[0] }, new int[] { borderColor.ToAndroid() }); + StrokeColor = new ColorStateList(new[] { new int[0] }, new int[] { borderColor.ToAndroid() }); } double borderWidth = Element.BorderWidth; @@ -249,10 +250,15 @@ void UpdateBorder() if (_defaultBorderWidth < 0) _defaultBorderWidth = StrokeWidth; + // TODO: The Material button does not support borders: + // https://github.com/xamarin/Xamarin.Forms/issues/4951 + if (borderWidth > 1) + borderWidth = 1; + if (borderWidth < 0f) StrokeWidth = _defaultBorderWidth; else - base.StrokeWidth = (int)Context.ToPixels(borderWidth); + StrokeWidth = (int)Context.ToPixels(borderWidth); } } diff --git a/Xamarin.Forms.Platform.iOS/Material/MaterialButtonRenderer.cs b/Xamarin.Forms.Platform.iOS/Material/MaterialButtonRenderer.cs index 89ffece5bdb..2d52d72f653 100644 --- a/Xamarin.Forms.Platform.iOS/Material/MaterialButtonRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/Material/MaterialButtonRenderer.cs @@ -33,7 +33,7 @@ public MaterialButtonRenderer() _buttonLayoutManager = new ButtonLayoutManager(this, preserveInitialPadding: true, spacingAdjustsPadding: false, - borderAdjustsPadding: true, + borderAdjustsPadding: false, collapseHorizontalPadding: true); } @@ -209,6 +209,11 @@ void UpdateBorder() if (_defaultBorderWidth == -1) _defaultBorderWidth = Control.GetBorderWidth(UIControlState.Normal); + // TODO: The Material button does not support borders: + // https://github.com/xamarin/Xamarin.Forms/issues/4951 + if (borderWidth > 1) + borderWidth = 1; + if (borderWidth == (double)Button.BorderWidthProperty.DefaultValue) Control.SetBorderWidth(_defaultBorderWidth, UIControlState.Normal); else