[英]Change font size in textinput react native based on screen size
i want to change fontSize
in textinput
based on screen width in react native.我想在本机反应中根据屏幕宽度更改
fontSize
输入中的textinput
大小。
i want to make something like this, expected result is the fontSize
go smaller when adding numbers to the textInput
我想做这样的事情,预期的结果是在向
textInput
添加数字时fontSize
go 更小
Resources i tried:我试过的资源:
React Native Responsive Font Size React Native 响应式字体大小
https://reactnativeexample.com/responsive-fontsize-based-on-screen-size-of-the-device-in-react-native/ https://reactnativeexample.com/responsive-fontsize-based-on-screen-size-of-the-device-in-react-native/
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小吃示例: https://snack.expo.io/PJeeBTGGe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.