How to change the font-size according to the view since flex-box doesn't allow changing its font-size in percent. I tried using dimension but that did not work.
You could scale your fontSize with this code snippet:
SCREEN_WIDTH = Dimensions.get('window').width; // get current width
SCALE = 375; // constant, 375 is standard width of iphone 6 / 7 / 8
const scaleFontSize = (fontSize) => {
const ratio = fontSize / SCALE; // get ratio based on your standard scale
const newSize = Math.round(ratio * SCREEN_WIDTH);
return newSize;
}
Now you can call scaleFontSize
with your standard fontSize and it will automatically be scaled.
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.