-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When resizeMode.contain is it possible not "center" the image? #493
Comments
I think you need to assign width and height to your image |
Like this?
Nothing changes. |
I believe that StyleSheet.absoluteFill it's centering the image |
Hey @rochapablo did you end up solving this? |
I'm having the same issue, I don't want my image to center with the contain resize mode. Have you figured it out? |
Hey @rochapablo , |
I just faced the same issue, - an image with <View
style={
justifyContent: 'flex-end',
}}
>
<Image
source={require('./img/source.png')}
style={{
// This is as strange as it gets. The `flex-end` setting works _only_ if I pass the image's aspect ratio
// and `undefined` for width and height properties. If any of these are missing, the image with `resizeMode="contain"
// will be centered vertically and ignore the `justifyContent` setting of the outer container.
aspectRatio: 0.5622, // In my case
width: undefined,
height: undefined,
resizeMode: 'contain',
}}
/>
</View> Hope this may help somebody. |
Hey @Valeriy-Burlaka, For me, Images are coming from url. I need to set every image's aspect ratio differently somehow. 🤔 |
No idea how, but this works! 💯 |
Describe the bug
I'm not sure if this is a bug, but following the code and image bellow, I notice that there's always a white space between the image, like the image it's been centered some how. I tried flex alignments but noting seems to work.
Using
resizeMode.contain
I got the white spaces; usingresizeMode.cover
I loose a little of the width.The white space increase as the image gets taller (huge height).
To Reproduce
Follow the code:
Expected behavior
The image should not have those white spaces at top and bottom of the element
<FastImage
.Screenshots
![Imgur](https://cdn.statically.io/img/camo.githubusercontent.com/fa7ae8dd3a17f3919c5f462b10f17571a613ac981ba319aecc59bd1c111bcba9/68747470733a2f2f692e696d6775722e636f6d2f366778573547332e706e67)
Dependency versions
Note: if these are not the latest versions of each I recommend updating as extra effort will not be taken to be backwards compatible, and updating might resolving your issue.
The text was updated successfully, but these errors were encountered: