user8811409
user8811409

Reputation: 569

React Native: Setting the width of a view equal to its height when using percentages

I have this stylesheet, and I'm trying to make the width of this equal to the height when I set height as a percentage. I the following with no success:

art: {
    height: "70%",
    width: styles.podcastArt.height,
    marginRight:10,
    marginTop:10,
    marginBottom:10,
},

Any ideas or direction would be helpful. Thanks!

Upvotes: 25

Views: 16647

Answers (1)

SiSa
SiSa

Reputation: 2684

set aspectRatio: 1

art: {
    height: "70%",
    aspectRatio: 1,
    marginRight:10,
    marginTop:10,
    marginBottom:10,
},

Upvotes: 70

Related Questions