Full width image using flexbox?
See original GitHub issueI’m attempting to make an image full-width and came across a few stackoverflow questions related where the top upvoted answer was to use flexbox similarly to how i’m using it below. Although it doesn’t seem to display the image unless i set static widths on my styles
property. Any ideas?
var styles = StyleSheet.create({
canvasContainer: {
flex:1,
alignItems: 'stretch'
},
canvas: {
flex:1
// width: 200,
// height: 200
}
});
render: function() {
return (
<View style={styles.container}>
<View style={styles.canvasContainer}>
<Image
source={{uri: 'http://imgs.steps.dragoart.com/how-to-draw-a-pony-step-7_1_000000053055_5.jpg'}}
style={styles.canvas} />
</View>
<ScrollView
style={styles.scrollView}
scrollEventThrottle={200}
contentInset={{top: 0}}
>
{this.state.messages.map(m => {
return <Text style={styles.message}>Josh: {m}</Text>
})}
</ScrollView>
</View>
)
}
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:33 (1 by maintainers)
Top Results From Across the Web
Stretching an image inside a flex item to full width
I am playing around with CSS Flexbox and media ...
Read more >Stretching an image inside a flex item to full width - CodePen
Answer to Stack Overflow question: http://stackoverflow.com/questions/35384232/stretching-an-image-inside-a-flex-item-to-full-width/35385309#35385309...
Read more >Adaptive Photo Layout with Flexbox - CSS-Tricks
Flexbox is great for filling up rows by determining cell width based on cell content. This meant the images (landscape or portrait) all...
Read more >How to Build a Full-Screen Responsive Page With Flexbox
In this tutorial, we'll learn how to build a full-screen responsive page with flexbox. Our page will include a full-screen background image, ...
Read more >Full-width pinned layouts with flexbox - Zoe Mickley Gillenwater
Full -width pinned layouts with flexbox. Learn how to use flexbox to pin two things to opposite ends of the viewport with a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have done according to this, Hope this code snippet might help you.
<Image style={styles.bgContainer} resizeMode='cover' source={require('./img/bg.png')} />
const styles = StyleSheet.create({ bgContainer: { flex:1, width: null, height: null } });
I have done without flex.
local image
network image