marudy / react-native-responsive-screen

Make React Native views responsive for all devices with the use of 2 simple methods
MIT License
1.55k stars 140 forks source link

Using heightPercentageToDP but with width keeping the same aspect ratio #112

Closed bananacity closed 9 months ago

bananacity commented 3 years ago

Hey so I will have a website made for one resolution 1440x840 for laptops.

Lets say I want it to scale up and down using heightPercentageToDP but I want the width to keep the same aspect ratio as in the original site is there a way to do this? The idea being on 1920x1080 for example there would be a bit of extra space on the sides so I don't want to specify widthPercentageToDP as this can change.

Also vice versa on mobile I would scale using widthPercentageToDP without specifying height percentage as that could change to show more content on taller devices etc.

mir1198yusuf commented 2 years ago

If I understand your question correctly, I would suggest to use for same container (example : some box on website) heightPercentageToDP for height (height or paddingVertical or marginVertical) and widthPercentageToDP for width (width or paddingHorizontal or marginHorizontal). So in this way the box would always be uniform irrespective of size.