How to ignore accessibility fonts resize in NativeScript?

不打扰是莪最后的温柔 提交于 2020-01-05 05:32:46

问题


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!


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/44903670/how-to-ignore-accessibility-fonts-resize-in-nativescript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!