react-native-slideshow
react-native-slideshow copied to clipboard
Set image resizeMode
how to set image resizeMode? And also set container height to full screen but keep image width not overflow or cropped. thanks
I'm new in react-native. My English is very bad. I hope you understand me.
I insert resizeMode={this.props.resizeMode} into 2 Image tag on about line 210 in Slideshow.js.
It's worked for me.
About resizeMode, reference: https://facebook.github.io/react-native/docs/image#resizemode
This is my change in Slideshow.js :
const imageComponent = ( <View key={index}> <Image source={imageObject} style={{ height, width }} resizeMode={this.props.resizeMode} /> {textComponent} </View> ); const imageComponentWithOverlay = ( <View key={index} style={styles.containerImage}> <View style={styles.overlay}> <Image source={imageObject} style={{ height, width }} resizeMode={this.props.resizeMode} /> </View> {textComponent} </View> );
In my class, i called it:
<Slideshow dataSource={this.state.dataSource} position={this.state.position} onPositionChanged={position => this.setState({ position })} height={Dimensions.get("window").height} resizeMode="contain" />
Hope it useful to you.