Font size is major issue when its come to mobile application. bigger font size can destroyed the screen. small font sizes also a problem.
So here is solution for font size problem in react native.
we will use NPM library called "react native responsive dimensions".
With this library we can import and use height, width and font size as our requirement of our mobile applications.
Install library:
Now import responsive dimensions:
Import style component for container:
Import style component for Font Sizes:
So here is solution for font size problem in react native.
we will use NPM library called "react native responsive dimensions".
With this library we can import and use height, width and font size as our requirement of our mobile applications.
Install library:
#npm
npm install --save react-native-responsive-dimensions
#yarn
yarn add react-native-responsive-dimensions
Now import responsive dimensions:
import { responsiveHeight, responsiveWidth, responsiveFontSize } from "react-native-responsive-dimensions";
Import style component for container:
container: { justifyContent: "center", height: responsiveHeight(50), // 50% of screen height width: responsiveWidth(50), // 50% of screen width alignItems: "center" }
Import style component for Font Sizes:
sampleText: { fontSize: responsiveFontSize(2) // 2% of total screen size }