Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why image has padding in React Native on Android?

Tags:

react-native

I'am using background image for the React Native application screen and want to squeeze image to the right side. On iOS look's good but on Android image has a padding from the right side. Why this happening? How to fix this? Thank's in advance!

<View style={{width: '100%', height: '100%', backgroundColor: '#fff',}}>
    <Image style={{flex: 1, resizeMode: 'contain',}} source={require('./../styles/image/building.png')}/>
</View>

enter image description here

like image 264
Evgeniy Avatar asked Nov 30 '25 19:11

Evgeniy


1 Answers

It's because you have different screen resolutions on one device vs the other. Your Android device my be wider. Change your resizeMode to 'cover'. I don't know how your containing View is positioned relative to its parent but it doesn't appear that your centering the image inside of it's view either. That's why the image padding is displayed on the right on wider devices.

<View style={{width: '100%', height: '100%', backgroundColor: '#fff', alignItems: 'center'}}>
    <Image style={{flex: 1, resizeMode: 'cover',}} source={require('./../styles/image/building.png')}/>
</View>
like image 194
Jo Momma Avatar answered Dec 02 '25 13:12

Jo Momma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!