xamarin/Xamarin.Forms
Effect that changes Label's background does not work when the FastRenderers flag is set
开放
#5,336 创建于 2019年2月21日
4.0.0a/fastrendererse/3 :clock3:help wantedinactivep/Androidt/bug :bug:up-for-grabs
仓库指标
- 星标
- (5,644 个星标)
- PR 合并指标
- (30 天内没有已合并 PR)
描述
Description
I've created an effect to show a border around many controls, everything seems good until I tested it while the FastRenderers flag is enabled, it worked for all my tests except for the Labels.
I'm creating the border by setting the TextView's background, I wasn't able to figure out the exact problem because the FastRenderers.LabelRenderer class is internal sealed and it's using the BackgroundManager which is also internal.
Steps to Reproduce
To reproduce the issue, I've modified the ShadowEffect sample project, I've just enabled the FastRenderers flag and modified the OnAttached override to set the Background instead of the ShadowLayer:
protected override void OnAttached()
{
try
{
var control = Control as Android.Widget.TextView;
var effect = (ShadowEffect)Element.Effects.FirstOrDefault(e => e is ShadowEffect);
if (effect != null)
{
Android.Graphics.Color color = effect.Color.ToAndroid();
if (!(control.Background is Android.Graphics.Drawables.GradientDrawable gradientBackground))
{
gradientBackground = new Android.Graphics.Drawables.GradientDrawable();
control.SetBackground(gradientBackground);
}
gradientBackground.SetStroke(1, color);
}
}
catch (Exception ex)
{
Console.WriteLine("Cannot set property on attached control. Error: ", ex.Message);
}
}
Expected Behavior
Actual Behavior
Basic Information
- Android Target Framework: 8.1 (API 27)
- Latest Xamarin.Forms (3.5.0.129452)