2016-12-03 79 views
0

为什么当我使用网络图像,阵营本地需要()网络与静态图像调整

<View style={{flex: 1, alignItems: 'stretch'}}> 
      <Image 
      style={{flex: 1}} 
      source={{uri: 'https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'}} /> 
</View> 

它填补了页: Google logo stretched across screen

但是当我使用要求()了静态图像:

<View style={{flex: 1, alignItems: 'stretch'}}> 
<Image 
    style={{flex: 1}} 
    source={require('./googlelogo.png')} /> 
</View> 

它不? enter image description here

运行react-native 0.37.0。这段代码直接添加到了新鲜的react-native init -ed项目中,没有任何第三方库或任何东西。

回答

1

也许您的问题与this相同。

尝试图像的宽度设置为null

<Image 
    style={{flex: 1, width: null}} 
    source={require('./googlelogo.png')} />