Answers for "full width image react native"

5

full width of image and maintain aspect ratio react native

render() {
    let image = this.props.requireSource;
    const { width, height } = Image.resolveAssetSource(image);
    const ratio = height / width;
    const SCREEN_WIDTH = Dimensions.get('window').width;

    return (
        <Image source={image} style={{width: SCREEN_WIDTH, height: SCREEN_WIDTH*ratio}} resizeMode="contain"/>
    );
}
Posted by: Guest on June-21-2021
1

react native cover image

// You want `resizeMode`
The options are 'cover' | 'contain' | 'stretch' | 'repeat' | 'center'
     
<Image
  style={{
    width: size,
    height: size,
    resizeMode: "contain", // <--
  }}
  source={...}
/>
Posted by: Guest on December-09-2021

Code answers related to "full width image react native"

Code answers related to "Javascript"

Browse Popular Code Answers by Language