kfiroo / react-native-cached-image

CachedImage component for react-native
MIT License
940 stars 468 forks source link

CachedImage default margin #103

Open witalobenicio opened 6 years ago

witalobenicio commented 6 years ago

When I pass a margin in my style, e.g.: "margin: 5", It's like the CachedImage already has a margin and my image is placed wrong. I have to pass "margin: 2.5" to work properly. How to avoid that?

witalobenicio commented 6 years ago

Another exemple:

<CachedImage
            resizeMethod={'scale'}
            style={[styles.imageItem, {backgroundColor: '#000'}]}
            source={{uri: this.props.source}}
          />

  imageItem: {
    margin: 6,
    alignItems: 'center',
    borderRadius: 10,
    height: 50,
    width: 50,
  },

Produces this.

captura de tela 2017-11-02 as 10 32 31
witalobenicio commented 6 years ago

It seems the problem is that if you pass only style={} it is applied to container and to image.

Blapi commented 6 years ago

Experiencing the same issue ! It drove me crazy for a little bit !

xihairanfeng commented 5 years ago

How to resolve this issue?

TopeMateo commented 5 years ago

Well, I wrapped the CachedImage with a View and moved the margin properties to the View component