Tôi muốn sử dụng hình nền trong ứng dụng gốc phản ứng của mình, hình ảnh nhỏ hơn màn hình, vì vậy tôi phải kéo dài nó.Làm cách nào để kéo dài một hình ảnh tĩnh làm nền trong React Native?
nhưng nó không hoạt động nếu hình ảnh là nạp từ bó tài sản
var styles = StyleSheet.create({
bgImage: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'stretch',
resizeMode: 'stretch',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
}
});
<Image source={require('image!background')} style={styles.bgImage}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
</Image>
nó trông như thế này:
tuy nhiên, nó hoạt động tốt cho hình ảnh từ xa , thông qua source={{uri: 'background-image-uri'}}
:
Thử 'resizeMode: 'cover''? tham khảo: [http://stackoverflow.com/questions/29322973/whats-the-best-way-to-add-a-full-screen-background-image-in-react-native](http://stackoverflow .com/questions/29322973/whats-the-best-way-to-add-a-full-screen-background-hình-trong-phản ứng-bản địa) – ddaaggeett