Answers for "how to make font size dynamic on react native"

9

dimensions react native

import { Dimensions } from 'react-native';

console.log({
	width: Dimensions.get('window').width,
	height: Dimensions.get('window').height
})
Posted by: Guest on June-11-2020
1

react native asign width to image

First import Dimensions from react-native

import { Dimensions } from 'react-native';
then you have to get the dimensions of the window

const win = Dimensions.get('window');
Now calculate ratio as

const ratio = win.width/541; //541 is actual image width
now the add style to your image as

imageStyle: {
    width: win.width,
    height: 362 * ratio, //362 is actual height of image
}
Posted by: Guest on November-04-2020

Code answers related to "how to make font size dynamic on react native"

Code answers related to "Javascript"

Browse Popular Code Answers by Language