Merge branch '3.2.0' into 3.3.0
This commit is contained in:
Коммит
2268657174
|
@ -59,15 +59,20 @@ namespace Xamarin.Forms.Platform.Android
|
||||||
if (colorToSet == Color.Default)
|
if (colorToSet == Color.Default)
|
||||||
colorToSet = Element.BackgroundColor;
|
colorToSet = Element.BackgroundColor;
|
||||||
|
|
||||||
if (_backgroundDrawable == null)
|
if (_backgroundDrawable != null) {
|
||||||
_backgroundDrawable = new GradientDrawable();
|
|
||||||
|
|
||||||
if (colorToSet != Color.Default)
|
if (colorToSet != Color.Default)
|
||||||
_backgroundDrawable.SetColor(colorToSet.ToAndroid());
|
_backgroundDrawable.SetColor(colorToSet.ToAndroid());
|
||||||
else
|
else
|
||||||
_backgroundDrawable.SetColor(colorToSet.ToAndroid(Color.Transparent));
|
_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)
|
protected override void Dispose(bool disposing)
|
||||||
|
@ -101,26 +106,32 @@ namespace Xamarin.Forms.Platform.Android
|
||||||
void UpdateCornerRadius()
|
void UpdateCornerRadius()
|
||||||
{
|
{
|
||||||
var cornerRadius = Element.CornerRadius;
|
var cornerRadius = Element.CornerRadius;
|
||||||
|
if (cornerRadius == new CornerRadius(0d)) {
|
||||||
if (Background is GradientDrawable backgroundGradient)
|
_backgroundDrawable?.Dispose();
|
||||||
{
|
_backgroundDrawable = null;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Загрузка…
Ссылка в новой задаче