Hi all,
I used to add an Effect to a Label whenever I wanted to set the maximum lines of text to show.
Now if I enable the FastRenderers, the code below does not work anymore.
It DOES work just fine when the FastRenderers flag is not set.
Any clues, please?
using System.Linq;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using Android.Text;
using PCLEffect = Sample.MultiLineEffect;
using Android.Widget;
[assembly: ExportEffect(typeof(Sample.Droid.Effects.MultiLineEffect), "MultiLine")]
namespace Sample.Droid.Effects
{
public class MultiLineEffect : PlatformEffect
{
protected override void OnAttached() {
var effect = (PCLEffect)Element.Effects.FirstOrDefault(e => e is PCLEffect);
if (Control is TextView tv) {
var maxLines = effect.MaxLines;
if (maxLines > 0) {
tv.Ellipsize = TextUtils.TruncateAt.End;
tv.SetSingleLine(false);
tv.SetMaxLines(maxLines);
}
}
}
protected override void OnDetached() {
}
}
}