NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Card Image dooesn't showing properly.

Open tishad770 opened this issue 9 years ago • 7 comments

Here is my code:

     <Card key={item['id']} >
            
          <CardItem cardBody>
                <Image
                    source={{uri: item['image']}}
                    style={{
                        alignSelf: 'stretch',
                        resizeMode: 'contain',
                        width: Dimensions.get('window').width,
                        marginRight: 10,
                        }}
                />
            </CardItem>

            <CardItem footer>
                <Text>Title</Text>

            </CardItem>
        </Card>

Its not working properly i.e: no image is being shown. Any idea what am I missing?

tishad770 avatar Apr 23 '17 11:04 tishad770

Same issue

rithvikvibhu avatar Apr 23 '17 16:04 rithvikvibhu

     <Card>
           <CardItem cardBody>
                <Image source={require('../images/test.jpg')} style={{  resizeMode: 'cover', height: 200, width: null, flex: 1 }} />
           </CardItem>
      </Card>

@rithvikvibhu @tishad770 the above should work for you guys .try it out

geekrishabh avatar Apr 24 '17 05:04 geekrishabh

@GeekRishabh thanks for that. What about external images? source={{uri:'https://upload.wikimedia.org/wikipedia/commons/d/de/Bananavarieties.jpg'}} used to work with any url for an image.

rithvikvibhu avatar Apr 24 '17 16:04 rithvikvibhu

I had a similar issue just now. The image, when placed inside a Card with a height of 180, will render on the simulator, but not on the device.

<Card>
      <CardItem cardBody>
        <Image
            source={item.thumbnail}
            style={styles.thumbnail}
        />
    </CardItem>
    <CardItem note>
        <Grid>
            <Row>
                <Text>{item.name}</Text>
            </Row>
            <Row>
                <Text>{item.description}</Text>
            </Row>
        </Grid>
    </CardItem>
</Card>
const styles = StyleSheet.create({
    thumbnail: {
        flex: 1,
        height: 180 // Changed this to >200
    }
});

Changing the height to anything larger than 200 fixed the issue. It renders fine on both now, the simulator and the device. 😕

ferdingler avatar Apr 24 '17 16:04 ferdingler

I also had several rendering issues with Card on devices, and I just ended up replacing all of them with custom styled view.

ishsingh avatar May 05 '17 07:05 ishsingh

There are many issues with the card item. For example: https://github.com/GeekyAnts/NativeBase/issues/612

I also changed to use custom styled views.

Anima-t3d avatar May 11 '17 03:05 Anima-t3d

screen shot 2017-05-31 at 5 11 35 pm

@tishad770 @rithvikvibhu @ferdingler @ishsingh @Anima-t3d Works fine. Tried with device as well, all good If both width and height is included for the Image.

You need to check the note mentioned in the docs of React Native for Image

@rithvikvibhu Yes external images still works with Image

SupriyaKalghatgi avatar May 31 '17 11:05 SupriyaKalghatgi