i want to change fontSize
in textinput
based on screen width in react native.
i want to make something like this, expected result is the fontSize
go smaller when adding numbers to the textInput
Resources i tried:
React Native Responsive Font Size
and much more didn't work.
You need to calculate relationship of text and container width together with letter spacing, margin etc.
fontsize = containerWidth / Math.max(text.length, 1) - adjustment
snack example here: https://snack.expo.io/PJeeBTGGe
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.