diff --git a/RoundedBoxView/RoundedBoxView/RoundedBoxView.Forms.Plugin.Android/ExtensionMethods/ViewExtensions.cs b/RoundedBoxView/RoundedBoxView/RoundedBoxView.Forms.Plugin.Android/ExtensionMethods/ViewExtensions.cs index 28c174c..d11ae79 100644 --- a/RoundedBoxView/RoundedBoxView/RoundedBoxView.Forms.Plugin.Android/ExtensionMethods/ViewExtensions.cs +++ b/RoundedBoxView/RoundedBoxView/RoundedBoxView.Forms.Plugin.Android/ExtensionMethods/ViewExtensions.cs @@ -64,7 +64,7 @@ public static void UpdateBorder(this View nativeControl, Color color, int thickn if (backgroundGradient != null) { - var relativeBorderThickness = thickness*3; + var relativeBorderThickness = (int)System.Math.Round(Xamarin.Forms.Forms.Context.ToPixels(thickness)); //#46 backgroundGradient.SetStroke(relativeBorderThickness, color.ToAndroid()); } } @@ -75,7 +75,7 @@ public static void UpdateCornerRadius(this View nativeControl, double cornerRadi if (backgroundGradient != null) { - var relativeCornerRadius = (float) (cornerRadius*3.7); + var relativeCornerRadius = Xamarin.Forms.Forms.Context.ToPixels(cornerRadius); //#46 backgroundGradient.SetCornerRadius(relativeCornerRadius); } } diff --git a/RoundedBoxView/RoundedBoxView/RoundedBoxView.Forms.Plugin.Android/RoundedBoxViewImplementation.cs b/RoundedBoxView/RoundedBoxView/RoundedBoxView.Forms.Plugin.Android/RoundedBoxViewImplementation.cs index 79b1d6a..0bc40be 100644 --- a/RoundedBoxView/RoundedBoxView/RoundedBoxView.Forms.Plugin.Android/RoundedBoxViewImplementation.cs +++ b/RoundedBoxView/RoundedBoxView/RoundedBoxView.Forms.Plugin.Android/RoundedBoxViewImplementation.cs @@ -34,5 +34,13 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE this.UpdateFrom(_formControl, e.PropertyName); } + + public override void SetBackgroundColor(Android.Graphics.Color color) + { + //Fix for #100, will prevent background from getting overriden on BackgroundColor property changed by Forms. + //Alternative fix would be to check propertyname in OnElementPropertyChanged, and skip if it's BackgroundColor. + // if(e.PropertyName != nameof(VisualElement.BackgroundColor)) + // base.OnElementPropertyChanged(sender, e); + } } } \ No newline at end of file