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

Most upvoted comments

Support for loading vector drawables has just landed in #45354. It’s currently sitting behind a feature flag called loadVectorDrawablesOnImages while 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. image

I´m using react-native-splash-screen for the splash flow