используйте react-native-responsive-screen
- отличный пакет для создания адаптивного макета https://www.npmjs.com/package/react-native-responsive-screen
или вы можете просто вычислить
import { PixelRatio } from 'react-native';
PixelRatio.roundToNearestPixel()
https://reactnative.dev/docs/pixelratio.html
import { Dimensions, PixelRatio } from 'react-native';
let Width = Dimensions.get('window').width;
let Height = Dimensions.get('window').height;
const wp = widthPercent => {
const elemWidth = typeof widthPercent === "number" ? widthPercent : parseFloat(widthPercent);
return PixelRatio.roundToNearestPixel(screenWidth * elemWidth / 100);
};
const hp = heightPercent => {
const elemHeight = typeof heightPercent === "number" ? heightPercent : parseFloat(heightPercent);
return PixelRatio.roundToNearestPixel(screenHeight * elemHeight / 100);
};
и используйте как
<View style={{height: hp(10), width: wp(20)}} >
<Text style={{fontSize: hp(3.4)}} />
</View>
hp процент высоты
wp процент ширины