Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image sizes for android and iOS in react-native

While making iOS Apps, we generally used to supply @x,@2x,@3x images. And based on my knowledge in case of android, there was some approx six different sizes

I have started working on react-native and came across the image issue.

My Question are: Do I need to provide images with all different sizes (i.e. approx 6-7 image sets by combining iOS and android) Or only 1 image and rest will be taken care internally? Will it look blurred on higher resolution phones?

Thanks.

like image 337
JiteshW Avatar asked Feb 16 '17 18:02

JiteshW


People also ask

Can React Native used for both iOS and Android?

Create native apps for Android, iOS, and more using React React Native combines the best parts of native development with React, a best-in-class JavaScript library for building user interfaces. Use a little—or a lot.

How do you fix the size of image in React Native?

resizeMode ​ contain : Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image will be equal to or less than the corresponding dimension of the view (minus padding). stretch : Scale width and height independently, This may change the aspect ratio of the src.

What is the size of a React Native app?

Apks are uploaded to the google play store and distributed according to their architecture. It can Reduces App Size React Native from 7MB to almost 3MB for armeabi and 5MB for x86.

What is aspect ratio in React Native?

Use aspectRatio wherever you can and avoid grabbing the window width using the Dimensions API. aspectRatio can make your components better adapt to change and in turn make your UI more stable. There is one caveat - this doesn't (yet) work with react-native-web, so if you're using that, it's best to avoid it.


1 Answers

You still need to provide multiple images. According to the Images documentation, if you are using an image named check.png, you also have to include [email protected] and [email protected].

Quoting:

The packager will bundle and serve the image corresponding to device's screen density. For example, [email protected], will be used on an iPhone 7, [email protected] will be used on an iPhone 7 Plus or a Nexus 5. If there is no image matching the screen density, the closest best option will be selected.

like image 178
RRikesh Avatar answered Oct 09 '22 16:10

RRikesh