import {Dimensions, PixelRatio} from 'react-native'; const widthPercentageToDP = widthPercent => { const screenWidth = Dimensions.get('window').width; // Convert string input to decimal number const elemWidth = parseFloat(widthPercent); return PixelRatio.roundToNearestPixel(screenWidth * elemWidth / 100); }; const heightPercentageToDP = heightPercent => { const screenHeight = Dimensions.get('window').height; // Convert string input to decimal number const elemHeight = parseFloat(heightPercent); return PixelRatio.roundToNearestPixel(screenHeight * elemHeight / 100); }; export { widthPercentageToDP, heightPercentageToDP };
Last active
April 13, 2018 07:11
-
-
Save ZainaliSyed/a393a4dcb4be218ecb7b02f854b87b6c to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment