Mark Estefanos
Mark Estefanos

Reputation: 543

How do I make an Image inherit its parent's size? (React Native)

Here's the layout I'd like:

Desired layout

Here's what happens when I add an image:

Current layout

I'd like Image to respect its parent sizing. How would I do that?

Upvotes: 3

Views: 3138

Answers (2)

rudydydy
rudydydy

Reputation: 795

try styling the image to

     width: null,
     height: null,
     flex: 1

Upvotes: 4

Mark Estefanos
Mark Estefanos

Reputation: 543

I ended up calculating the width of the image manually by just doing this:

screenWidth/7 - margin

This is a hack, so if anyone has a proper way of doing it I'd love to hear it!

Upvotes: 1

Related Questions