Reputation: 481
I put my images in drowable-*dpi folders, The image name without capital letters, and its legal name. The prefix is .png In index.android.js file:
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Image
} from 'react-native';
export default class proj extends Component {
render() {
return (
<View style={styles.container}>
<Image source={{uri: 'background_home'}} style={{width: 40, height: 40}} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
});
AppRegistry.registerComponent('proj', () => proj);
When I run this code -> nothing... the image not shown on my android device.
What can I do to resolve this issue?
Upvotes: 0
Views: 1670
Reputation: 5193
There is no support for accessing images under mipmap directory in react-native as of now.
Create a directory called drawable
under res
directory (Parent directory of mipmap-*
). Put your images in that directory. Then your code will work.
Later move all your images based on density to respective directories like drawable-hdpi
,drawable-xhdpi
,drawable-xxhdpi
etc.
Upvotes: 2