Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29506

how to normalize font size?

$
0
0

In android, you can increase the font size. If you use the maximum font, the layout will break. You need to come up with a formula so that when you change the font size on the device, the font size in the application is the same. This applies not only to the Text component, but to all components (input, icons, etc.)

At the moment there is such a formula, but it is not finalized, tell me how to solve the problem

import { PixelRatio } from 'react-native';export function FontSize (size, px) {  if (px) {    return `${ Math.round(size / PixelRatio.getFontScale()) + 1 }${ px === true ? 'px' : px }`;  } else {    return Math.round(size / PixelRatio.getFontScale()) + 1;  }}

Viewing all articles
Browse latest Browse all 29506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>