A React Native Responsive Dimension
npm install react-native-dimensionwidth: 50% or height: 70% { width: width(50) } or { height: height(70) } { fontSize: totalSize(2) } (this means the font size will be 2% of your total size of the screen) npm install --save react-native-dimensionjsx
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
} from 'react-native';
import { width, height, totalSize } from 'react-native-dimension';class MyExample extends Component {
render() {
return (
Yeah... This is awesome!
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 20,
},
textWrapper: {
height: height(70), // 70% of height device screen
width: width(80), // 80% of width device screen
backgroundColor: 'yellow',
},
myText: {
fontSize: totalSize(2) // 2% of total screen size
}
});
export default MyExample;
``