I am trying to display static images in my react-native android and iOS apps. It's working fine with iOS app. But I am not able to display image in android app. Following is my code:
<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'
}
I have put the image 'background.png' under drawable-**dpi folders as well as under the mentioned images folder.
It works well in my iOS app picking image from images folder but not on android. I am using react-native version 0.33
Any help in this will be greatly appreciated!
Edit: It doesn't work here also:
<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>
I have put the image_holo.png under same directory as js file and respective drawable-**dpi folders. It works on iOS. But not on android!