Forum Xamarin.Forms

Accessibility scaling for Named Font Size

I have an app in android which looks as required when accessibility "Font Size" & "Display Size" setting is set to "Default". I am using NamedSize.Small and NamedSize.Medium in most places.

But when I change both of them to maximum possible value then size of labels are getting increased by 3-4 times. And also font size get increase if I changed Font Size or display size. So I would like to know whether there is any option where I can manage the ratio I want to change when "Font Size" & "Default Size" is changed. And whether there is any properties which suggest which of the two is changed and how much. Or may be disable "Default Size" changes and only allow "Font Size" to work.

I know there is "Density" & "ScaledDensity" in DisplayMetrics class. But can't find how it work and how to use those properties.

Same applies to iOS when accessibility setting in that. So far I have only found that there is a property "EnableAccessibilityScalingForNamedFontSizes" to disable accessibility scaling for named font sizes

Thanks,
Gaurav Khanna

Answers

  • JohnHardmanJohnHardman GBUniversity admin

    @GauravKhanna said:
    Same applies to iOS when accessibility setting in that. So far I have only found that there is a property "EnableAccessibilityScalingForNamedFontSizes" to disable accessibility scaling for named font sizes

    Needless to say, nobody should be disabling scaling of font sizes...

  • JadenNxJadenNx NZMember ✭✭

    @GauravKhanna

    Here is a link how to do this from Sync fusion https://www.syncfusion.com/kb/11506/how-to-prevent-system-font-size-changing-effects-to-android-application-in-xamarin-forms

    But you just need to add this in your MainActivity.cs

      public override Resources Resources
            {
                get
                {
                    Resources resource = base.Resources;
                    Configuration configuration = new Configuration();
                    configuration.SetToDefaults();
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.NMr1)
                    {
                        return CreateConfigurationContext(configuration).Resources;
                    }
                    else
                    {
                        resource.UpdateConfiguration(configuration, resource.DisplayMetrics);
                        return resource;
                    }
                }
            }
    
Sign In or Register to comment.