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!
To set width style to a percentage number with React Native, we can use flexbox. to set flexDirection to 'row' to add a horizontal flexbox layout. We set the 2nd Text component to fill 20% of the screen. Then we set flexGrow to 1 on the first Text component to expand to fill the remaining width of the screen.
In react-native, to set the dynamic width and height to a component, we use built-in interface Dimensions. it takes the dimension of a given component and then sets the width and height to its equivalent.
set aspectRatio: 1
art: { height: "70%", aspectRatio: 1, marginRight:10, marginTop:10, marginBottom:10, },
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With