react-native: [Android] Vector images from native resources is not working
Based on React Native documentation, we should be able to fetch images from native resources.
This is works great on iOS, but in Android you can’t load vector images using uri.
React Native version:
react-native: 0.61.5
Steps To Reproduce
Placing vector image named image.xml in drawable folder and using this code, is not working:
<Image width={100} height={100} source={{ uri: 'image' }} style={{ width: 100, height: 100 }} />
Placing the vector image in assets folder and using this code, is not working either:
<Image width={100} height={100} source={{ uri: 'asset:/image.xml' }} style={{ width: 100, height: 100 }} />
Note that placing .jpg or .png images is working without any issues.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 9
- Comments: 18 (1 by maintainers)
Commits related to this issue
- Support loading vector drawables in ImageView Summary: Fresco has indicated that they have no plans to support loading vector assets and similar drawable types in Drawee-backed views ([issue](https:/... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Support loading vector drawables in ImageView (#45354) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45354 Fresco has indicated that they have no plans to support loa... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Add feature flag to enable vector drawable support Summary: Changelog: [Internal] The current `Image` implementation does not support loading [vector drawables](https://developer.android.com/develop... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Add feature flag to enable vector drawable support (#45394) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45394 Changelog: [Internal] The current `Image` implementat... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Add feature flag to enable vector drawable support (#45394) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45394 Changelog: [Internal] The current `Image` implementat... — committed to facebook/react-native by Abbondanzo 2 years ago
- Support loading vector drawables in ImageView (#45354) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45354 Fresco has indicated that they have no plans to support loa... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Support loading vector drawables in ImageView Summary: Fresco has indicated that they have no plans to support loading vector assets and similar drawable types in Drawee-backed views ([issue](https:/... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Support loading vector drawables in ImageView (#45354) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45354 Fresco has indicated that they have no plans to support loa... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Support loading vector drawables in ImageView Summary: Fresco has indicated that they have no plans to support loading vector assets and similar drawable types in Drawee-backed views ([issue](https:/... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Support loading vector drawables in ImageView (#45354) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45354 Fresco has indicated that they have no plans to support loa... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Support loading vector drawables in ImageView Summary: Fresco has indicated that they have no plans to support loading vector assets and similar drawable types in Drawee-backed views ([issue](https:/... — committed to Abbondanzo/react-native by Abbondanzo 2 years ago
- Support loading vector drawables in ImageView (#45354) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45354 Fresco has indicated that they have no plans to support loa... — committed to facebook/react-native by Abbondanzo 2 years ago
Support for loading vector drawables has just landed in #45354. It’s currently sitting behind a feature flag called
loadVectorDrawablesOnImageswhile we investigate performance implications of parsing every local image resource. If all goes well and there aren’t any regressive behaviors from this change, I’m going to try and get this out in 0.76.0.Separately, I’m also working on adding Metro support so you can import vector drawable images same as you would any other image by import.
still exist in version 0.63.1
I solved it, creating any other container for example Linear Layout and putting svg as background <LinearLayout android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_centerInParent = "true" android: background = "@ drawable / ic_splash_icon" android: orientation = "horizontal"> </LinearLayout> and works fine.
I´m using react-native-splash-screen for the splash flow