3

On Android, it's possible for the user to set a larger font for accessibility reasons.

Discussions like this one go into some details on how/whether the named or fixed (number) sizes are affected by accessibility settings.

I have a slightly different question. Is there a way to adjust the size of controls to account for font size? With our app, if the user sets a large font size under Accessibility, then the text in buttons, Infragistics DataGrids, ListViews etc. don't fit into their controls. Am I missing something?

James Lavery
  • 920
  • 4
  • 25

1 Answers1

3

it's possible for the user to set a larger font for accessibility reasons.

You could try using the following code to implement this feature:

 private void initFontScale()
 {
      Configuration configuration = Resources.Configuration;
      configuration.FontScale = (float)1.45;
      //0.85 small, 1 standard, 1.15 big,1.3 more bigger ,1.45 supper big 
      DisplayMetrics metrics = new DisplayMetrics();
      WindowManager.DefaultDisplay.GetMetrics(metrics);
      metrics.ScaledDensity = configuration.FontScale * metrics.Density;
      BaseContext.Resources.UpdateConfiguration(configuration, metrics);
}

protected override void OnCreate(Bundle bundle)
{
    initFontScale();
    ...
}

Discussions like this one go into some details on how/whether the named or fixed (number) sizes are affected by accessibility settings.

I don't really understand what you mean, if you need set a fixed text size for your application, you could refer to:

how to prevent system font-size changing effects to android application?

York Shen
  • 9,014
  • 1
  • 16
  • 40
  • What I mean in my post is how to allow for the user changing the font under accessibility settings. I think the code (and link) have the solution. – James Lavery Feb 16 '18 at 12:55
  • Although I have yet to try the suggestion in the link above, this looks like the right approach, hence setting as the answer to my question. – James Lavery Feb 16 '18 at 13:05