Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Custom Renderer for Span

$
0
0

Hello devs!

I'm trying to make a Custom Renderer to ignore the android accessibility configurations in the Span Class, to not re-scale the font size.
I have made successfully renderer for the Label class but not for Span class.. Can someone help me? :D

My Label Custom Renderer is Above!

using System;
using System.ComponentModel;
using Android.Widget;
using FreePlay.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(Span), typeof(IgnoreAcessibilitySpan))]
namespace FreePlay.Droid
{

    public class IgnoreAcessibilitySpan : LabelRenderer
    {

        protected void setFontSizeAgain()
        {
            var nativeControl = (TextView)Control;
            var xfControl = Element; //e.NewElement;
            if (nativeControl != null && xfControl != null)
                nativeControl.SetTextSize(Android.Util.ComplexUnitType.Dip, xfControl.Font.ToScaledPixel());
        }

        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Label> e)
        {
            base.OnElementChanged(e);
            setFontSizeAgain();
        }

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            setFontSizeAgain();
        }
    }
}


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>