全屏背景图像的行为不同于网络和本地存储
Full Screen Background Image behaves differently from network and local storage
我正在尝试将背景图像拉伸到全屏。
从网络和本地存储中获取图像时,图像的行为似乎有所不同。
此函数未按要求拉伸图像(右侧有大约 70 像素的白边):
这是我的 render() 基金:
var BackgroundImage = require('./images/logo_og.png');
render(){
return(
<View style={[{flex: 1, alignItems: 'stretch'}]}>
<Image source={BackgroundImage} style={[{flex: 1}]} >
</Image>
</View>
);
相同的渲染函数可以很好地显示从网络获取的图像:
render(){
return(
<View style={[{flex: 1, alignItems: 'stretch'}]}>
<Image source={{uri:'https://facebook.github.io/react/img/logo_og.png'}} style={[{flex: 1}]} >
</Image>
</View>
);
知道发生了什么事吗?
已报告类似问题 here。尝试将图像的宽度设置为 null
:
<Image source={BackgroundImage} style={[{flex: 1, width: null}]} >
我正在尝试将背景图像拉伸到全屏。
从网络和本地存储中获取图像时,图像的行为似乎有所不同。
此函数未按要求拉伸图像(右侧有大约 70 像素的白边): 这是我的 render() 基金:
var BackgroundImage = require('./images/logo_og.png');
render(){
return(
<View style={[{flex: 1, alignItems: 'stretch'}]}>
<Image source={BackgroundImage} style={[{flex: 1}]} >
</Image>
</View>
);
相同的渲染函数可以很好地显示从网络获取的图像:
render(){
return(
<View style={[{flex: 1, alignItems: 'stretch'}]}>
<Image source={{uri:'https://facebook.github.io/react/img/logo_og.png'}} style={[{flex: 1}]} >
</Image>
</View>
);
知道发生了什么事吗?
已报告类似问题 here。尝试将图像的宽度设置为 null
:
<Image source={BackgroundImage} style={[{flex: 1, width: null}]} >