1
votes

I'm using NativeScript with Angular. Is there an attribute to specify on Labels/buttons to ignore the font increase due to accessibility settings? I need a solution for both android and ios. Thank you!

2
Why would you want to? What if a user needs to read something? - mast3rd3mon
I want to control this on certain elements and increase only for the important ones, to create a suitable view for all modes. - tigrenok00

2 Answers

1
votes

If anybody interested, I found a workaround of using FormattedString for Labels, this object does not scale.

1
votes

I just had a look a NativeScript own code and noticed this:

https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/ui/text-base/text-base.android.ts#L216

You could try this:

HTML:

<Label text="Fixed size text" (loaded)="fixedFontSize($event)"></Label>

TypeScript

import { Label } from 'ui/label';
...
fixedFontSize({object}, fontSize = 20) {
  const label = <Label>object;

  if (label.android) {
   label.nativeView.setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, utils.layout.toDevicePixels(fontSize));

  }
}

This should lock the fontSize of the label, until the CSS is changed.