Forum Xamarin.Forms

How to use TextView.SetAutoSizeTextTypeWithDefaults(AutoSizeTextType.Uniform) ?

Is it possible (and if so, how) to use TextView.SetAutoSizeTextTypeWithDefaults(AutoSizeTextType.Uniform) in a Xamarin.Forms Android custom renderer?

I am using v25.3.1 of the Xamarin.Android.Support.v4 NuGet package. When I try to use that method, I get a Java.Lang.NoSuchMethodError exception. My MainActivity subclasses FormsAppCompatActivity

Best Answer


  • JohnHardmanJohnHardman GBUniversity mod

    @JamesMontemagno - I noticed that you referred to this functionality at . Do you know if it's possible to use it using v25.3.1 of the Xamarin.Android.Support.v4 NuGet package, or using a newer version?

  • JohnHardmanJohnHardman GBUniversity mod

    Thanks @BillyLiu

  • GabrielBunselmeyerGabrielBunselmeyer Member ✭✭
    edited November 2018

    How exactly did you use this feature, @JohnHardman?
    I've been trying to add it to an Effect's OnAttached property without much luck.

    Code's quite simple:

    protected override void OnAttached()
                var textView = Control as TextView;
                if (textView == null)

    Yet I've been getting the following error:

    Java.Lang.NoSuchMethodError: no non-static method "Landroid/widget/TextView;.setAutoSizeTextTypeWithDefaults(I)V"

    I assume it has to do with the Android or support library versions (that semicolon shouldn't be there, should it?), though the build target is 8.1 (v27), with the Android.Support.v4 lib updated accordingly (v27.0.2.1). Tried downgrading/changing the build target to no avail.

    Oh, the device I've been using is on API 23, so it shouldn't be a problem as the feature works with API 14+.

  • JohnHardmanJohnHardman GBUniversity mod

    I took it out in the end. I didn't comment why unfortunately and I cannot remember for sure.

  • JohnHardmanJohnHardman GBUniversity mod

    I remembered why. It didn't scale the text in the way I expected. I've reverted to using an Effect instead, although I still need to make some tweaks to that.

  • JuttaJutta Member ✭✭

    I know this goes back a few months now, but did you ever find a solution to this, @GabrielBunselmeyer? I'm having exactly the same problem.

Sign In or Register to comment.