2016-12-03 46 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')} />