Permalink
Browse files

Document URI for Android asset folder images

Summary:
How to load images from the Android assets folder was undocumented, and took us a little while to find out how to do it.

This is a documentation-only change.

To confirm the syntax works create a sample app with an image at `android/app/src/main/assets/foo.png`.

Then add JSX `<Image style={{width:100, height:100}} source={{uri: 'asset:/foo.png'}} />`.

See that the image is rendered (Android only).
Closes #14626

Differential Revision: D5316887

Pulled By: AaaChiuuu

fbshipit-source-id: f7d07b8b83d6460de86c1a2efac0955300cfcd78
  • Loading branch information...
benvium authored and facebook-github-bot committed Jun 24, 2017
1 parent 08b8216 commit a38f5b6b6a5013f31772141291716be3c4feeef0
Showing with 9 additions and 2 deletions.
  1. +9 −2 docs/Images.md
View
@@ -75,14 +75,21 @@ A caveat is that videos must use absolute positioning instead of `flexGrow`, sin
## Images From Hybrid App's Resources
If you are building a hybrid app (some UIs in React Native, some UIs in platform code) you can still use images that are already bundled into the app (via Xcode asset catalogs or Android drawable folder):
If you are building a hybrid app (some UIs in React Native, some UIs in platform code) you can still use images that are already bundled into the app.
For images included via Xcode asset catalogs or in the Android drawable folder, use the image name without the extension:
```javascript
<Image source={{uri: 'app_icon'}} style={{width: 40, height: 40}} />
```
This approach provides no safety checks. It's up to you to guarantee that those images are available in the application. Also you have to specify image dimensions manually.
For images in the Android assets folder, use the `asset:/` scheme:
```javascript
<Image source={{uri: 'asset:/app_icon.png'}} style={{width: 40, height: 40}} />
```
These approaches provide no safety checks. It's up to you to guarantee that those images are available in the application. Also you have to specify image dimensions manually.
## Network Images

0 comments on commit a38f5b6

Please sign in to comment.