2017-01-04 15 views

Odpowiedz

6
<Image source={require('./images/MacWallPaper.jpg')} style={styles.container}> 

</Image> 

Jeśli nie określisz width: null i height: null komponent pobiera rzeczywista szerokość i wysokość obrazu źródłowego.

container: { 
    flex: 1, 
    justifyContent: 'center', 
    alignItems: 'center', 
    backgroundColor: 'rgba(0, 0, 0, 0)', 
} 

kiedy jawnie określić width: null i height: null składnik nie będzie korzystał z rzeczywistej szerokości i wysokości obrazu.

container: { 
    flex: 1, 
    justifyContent: 'center', 
    alignItems: 'center', 
    backgroundColor: 'rgba(0, 0, 0, 0)', 
    // remove width and height to override fixed static size 
    width: null, 
    height: null, 
} 

Watch this wideo