From 02096e1a0448bb204e0cfbd9958f0bb1388f9a64 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Thu, 20 Sep 2018 19:05:33 +0200 Subject: [PATCH 1/2] [A] do not draw gradient for empty CornerRadius (#3786) Drawing CornerRadius (introduce by #1998) when the CornerRadii are actually 0 causes scaling artifacts on API < 25. This fixes the regression when no CornerRadius is set. Expect blurry border scaling with CornerRadius not empty and API < 25 - fixes #3781 --- .../Renderers/BoxRenderer.cs | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs index c9a023da9..8415db592 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs @@ -59,15 +59,20 @@ namespace Xamarin.Forms.Platform.Android if (colorToSet == Color.Default) colorToSet = Element.BackgroundColor; - if (_backgroundDrawable == null) - _backgroundDrawable = new GradientDrawable(); + if (_backgroundDrawable != null) { - if (colorToSet != Color.Default) - _backgroundDrawable.SetColor(colorToSet.ToAndroid()); - else - _backgroundDrawable.SetColor(colorToSet.ToAndroid(Color.Transparent)); + if (colorToSet != Color.Default) + _backgroundDrawable.SetColor(colorToSet.ToAndroid()); + else + _backgroundDrawable.SetColor(colorToSet.ToAndroid(Color.Transparent)); - this.SetBackground(_backgroundDrawable); + this.SetBackground(_backgroundDrawable); + } + else { + if (colorToSet == Color.Default) + colorToSet = Element.BackgroundColor; + SetBackgroundColor(colorToSet.ToAndroid(Color.Transparent)); + } } protected override void Dispose(bool disposing) @@ -101,26 +106,32 @@ namespace Xamarin.Forms.Platform.Android void UpdateCornerRadius() { var cornerRadius = Element.CornerRadius; - - if (Background is GradientDrawable backgroundGradient) - { - var cornerRadii = new[] - { - (float)(cornerRadius.TopLeft), - (float)(cornerRadius.TopLeft), - - (float)(cornerRadius.TopRight), - (float)(cornerRadius.TopRight), - - (float)(cornerRadius.BottomRight), - (float)(cornerRadius.BottomRight), - - (float)(cornerRadius.BottomLeft), - (float)(cornerRadius.BottomLeft) - }; - - backgroundGradient.SetCornerRadii(cornerRadii); + if (cornerRadius == new CornerRadius(0d)) { + _backgroundDrawable?.Dispose(); + _backgroundDrawable = null; } + else { + this.SetBackground(_backgroundDrawable = new GradientDrawable()); + if (Background is GradientDrawable backgroundGradient) { + var cornerRadii = new[] { + (float)(cornerRadius.TopLeft), + (float)(cornerRadius.TopLeft), + + (float)(cornerRadius.TopRight), + (float)(cornerRadius.TopRight), + + (float)(cornerRadius.BottomRight), + (float)(cornerRadius.BottomRight), + + (float)(cornerRadius.BottomLeft), + (float)(cornerRadius.BottomLeft) + }; + + backgroundGradient.SetCornerRadii(cornerRadii); + } + } + + UpdateBackgroundColor(); } } } \ No newline at end of file From aeca07c097e5dfaa1ec06949b8641a079676af64 Mon Sep 17 00:00:00 2001 From: Matthew Richardson Date: Wed, 27 Jun 2018 11:30:27 +0100 Subject: [PATCH 2/2] Fix #3097 swipe gesture not being handled in VisualElementTracker. (#3098) Fixes #3097 --- Xamarin.Forms.Platform.UAP/VisualElementTracker.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Xamarin.Forms.Platform.UAP/VisualElementTracker.cs b/Xamarin.Forms.Platform.UAP/VisualElementTracker.cs index be662ffe6..a6a5a47c0 100644 --- a/Xamarin.Forms.Platform.UAP/VisualElementTracker.cs +++ b/Xamarin.Forms.Platform.UAP/VisualElementTracker.cs @@ -624,7 +624,7 @@ namespace Xamarin.Forms.Platform.UWP bool hasSwipeGesture = gestures.GetGesturesFor().GetEnumerator().MoveNext(); bool hasPinchGesture = gestures.GetGesturesFor().GetEnumerator().MoveNext(); bool hasPanGesture = gestures.GetGesturesFor().GetEnumerator().MoveNext(); - if (!hasPinchGesture && !hasPanGesture) + if (!hasSwipeGesture && !hasPinchGesture && !hasPanGesture) return; //We can't handle ManipulationMode.Scale and System , so we don't support pinch/pan on a scrollview