Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image cut off with resizeMode cover

I have an image, when I want to make it bigger using resizeMode="cover", part of the image is cut off. How to fix that?

render() {
    return (
         <View style={styles.container}>       
            <Image
              style={styles.imgStyleGoogle}
              source={{uri: 'my.png'}}
            />
        <View>
    )
}
const styles = StyleSheet.create({
  container: {
        flex: 1,
        alignItems:  'center',
        marginLeft: ratio * 5,
        marginRight: ratio * 5,
    },

imgStyleGoogle: {
        flex: 1,
        height: ratio*25,
        width: ratio*100,
        resizeMode:'cover',
    }
})

Here is example of the picture: enter image description here

like image 417
Lucky_girl Avatar asked Oct 19 '17 10:10

Lucky_girl


1 Answers

I found the solution, the problem was with flex: 1 in Image, I deleted it from imgStyleGoogle and changed resizeMode:'contain', and there is no more image cut off.

like image 145
Lucky_girl Avatar answered Sep 16 '22 23:09

Lucky_girl