【发布时间】:2016-10-03 13:41:57
【问题描述】:
我正在尝试在我的 react-native android 和 iOS 应用程序中显示静态图像。它适用于 iOS 应用程序。但我无法在 android 应用程序中显示图像。以下是我的代码:
<Image source ={require('../images/background.png')}
style ={styles.imageStyle}>
</Image>
var styles = StyleSheet.create({
container: {
flex: 1,
alignSelf: 'stretch'
},
imageStyle: {
flex: 1,
margin:10,
width: undefined,
height: undefined,
backgroundColor:'transparent',
justifyContent: 'center',
alignItems: 'center'
}
我已将图像“background.png”放在 drawable-**dpi 文件夹以及上述图像文件夹下。
它适用于我的 iOS 应用程序从图像文件夹中选择图像,但不适用于 android。 我正在使用 react-native 版本 0.33
我们将不胜感激任何帮助!
编辑: 它在这里也不起作用:
<View key={answer.ID}>
<OnTouchHighlightWidget key={answer.ID} onPress={() => {this.props.onSelect(answer)}}>
<Image source={this.getImageUrl(answer)} style={{flex:1,margin:10,width: 90, height: 95}} />
</OnTouchHighlightWidget>
</View>
我已将 image_holo.png 与 js 文件和相应的 drawable-**dpi 文件夹放在同一目录下。它适用于 iOS。但不是在安卓上!
【问题讨论】:
-
这是全封面背景图?
-
是的。这是一张背景图片。
标签: android react-native