Reputation: 848
i'm working on an application with react native on android. i would like to put some Image components on the screen and load them with some local image files. can someone provide the directory (relative to the project's root directory) in which i should place my files ? the docs don't seem to provide any useful information on this.
Upvotes: 3
Views: 5188
Reputation: 2226
From the example here:
https://facebook.github.io/react-native/docs/image.html#adding-static-resources-to-your-android-app
Adding Static Resources to your Android app Add your images as bitmap drawables to the android project (/android/app/src/main/res). To provide different resolutions of your assets, check out using configuration qualifiers. Normally, you will want to put your assets in the following directories (create them under res if they don't exist):
- drawable-mdpi (1x)
- drawable-hdpi (1.5x)
- drawable-xhdpi (2x)
- drawable-xxhdpi (3x)
If you're missing a resolution for your asset, Android will take the next best thing and resize it for you.
NOTE: App build required for new resources Any time you add a new resource to your drawables you will need to re-build your app by running
react-native run-android
before you can use it - reloading the JS is not enough. This process is currently being improved, a much better workflow will be available shortly.
Upvotes: 3