Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Scroll View not showing image

The below is my code of react native app code. But its not showing the image. i Moved the container style from scroll view to image the the image showed in an incorrect way.

<ScrollView vertical={true} style={styles.container} >
  <Image
    style={{ width: '100%', height: '100%' }}
    source={{ uri: this.props.navigation.state.params.PassedURL }}>
  </Image>
</ScrollView>

here the container style

container: {
  flex: 1,
  backgroundColor: 'gray',
  padding: 10
},

There is nothing other to render on the screen

like image 687
Savad Avatar asked Oct 20 '25 17:10

Savad


2 Answers

Don't use flex:1 in ScrollView, if that doesn't fix it try to set specific width and height as suggested by others

<ScrollView vertical={true} style={styles.container} >
   <Image
     style={{ width: 200, height: 200 }}
     source={{ uri: this.props.navigation.state.params.PassedURL }}>
    />
</ScrollView>

The container style

container: {
  backgroundColor: 'gray',
  padding: 10
},

EDIT:

If you want it to fill to full width just set width to 100% and the height will be ajusted accordingly and maybe put resizeMode="contain" or "cover" depending on your need

like image 93
MPN7 Avatar answered Oct 23 '25 07:10

MPN7


it is because you configure image height and weight with percentage

<Image
    style={{ width: '100%', height: '100%' }}
    source={{ uri: this.props.navigation.state.params.PassedURL }}>
</Image>

try to set it with exact number ,percentage only work with only one width or heigth not both

<Image
    style={{ width: 100, height: 100 }}
    source={{ uri: this.props.navigation.state.params.PassedURL }}>
</Image>
like image 30
Khadam Ikhwanus Avatar answered Oct 23 '25 05:10

Khadam Ikhwanus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!