Skip to content

Commit

Permalink
Avoid create a drawable to set the Background if is not necessary (#1504
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jsuarezruiz authored Jul 1, 2021
1 parent f245183 commit c461a3b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Core/src/Platform/Android/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c461a3b

Please sign in to comment.