From c461a3bf23021acdb228571d1a53bc159158152d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez?= Date: Thu, 1 Jul 2021 15:25:50 +0200 Subject: [PATCH] Avoid create a drawable to set the Background if is not necessary (#1504) --- src/Core/src/Platform/Android/ViewExtensions.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Core/src/Platform/Android/ViewExtensions.cs b/src/Core/src/Platform/Android/ViewExtensions.cs index adfd94f00cc0..9a801f107e41 100644 --- a/src/Core/src/Platform/Android/ViewExtensions.cs +++ b/src/Core/src/Platform/Android/ViewExtensions.cs @@ -52,7 +52,17 @@ public static void UpdateBackground(this AView nativeView, IView view, Drawable? if (paint.IsNullOrEmpty()) nativeView.Background = defaultBackground; else - nativeView.Background = paint!.ToDrawable(); + { + if (paint is SolidPaint solidPaint) + { + Color backgroundColor = solidPaint.Color; + + if (backgroundColor != null) + nativeView.SetBackgroundColor(backgroundColor.ToNative()); + } + else + nativeView.Background = paint!.ToDrawable(); + } } public static void UpdateOpacity(this AView nativeView, IView view)