Cannot display SVG image
See original GitHub issueDescription
I am trying to use the SvgCachedImage to display a SVG image. However, it’s not displaying for some odd reason. When I try with a PNG image it works fine. I am trying to do it in Xamarin.Forms. This is the code snippet:
<ffimageloadingsvg:SvgCachedImage HeightRequest="48" WidthRequest="48" Source="backbutton.svg"> <ffimageloadingsvg:SvgCachedImage.GestureRecognizers> <TapGestureRecognizer Tapped="OnBackButtonPressed" /> </ffimageloadingsvg:SvgCachedImage.GestureRecognizers> </ffimageloadingsvg:SvgCachedImage>
I have installed the nuget plugin, and I do have xmlns:ffimageloadingsvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
I have tried with two different SVG images.
Expected Behavior
The SVG image is displayed
Actual Behavior
The SVG image is not displayed
Basic Information
-
Version with issue: 2.3.3
-
Platform: Xamarin.Forms
Reproduction Link / Code
<ffimageloadingsvg:SvgCachedImage HeightRequest="48" WidthRequest="48" Source="backbutton.svg"> <ffimageloadingsvg:SvgCachedImage.GestureRecognizers> <TapGestureRecognizer Tapped="OnBackButtonPressed" /> </ffimageloadingsvg:SvgCachedImage.GestureRecognizers> </ffimageloadingsvg:SvgCachedImage>
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
I did some measures recently and it’s almost the same (sometimes even faster). SVG files are smaller in size, so reading stream from assets is a lot faster, leading to similar loading time. After image is decoded it’s cached as any other image. There could be a performance issue for a really large and complex SVG files when decoding though.
BTW: I use SVG’s in almost all projects, it’s such a time saver.
I updated samples to also replace colors. You can also use regex as mentioned here: https://github.com/luberda-molinet/FFImageLoading/wiki/SVG-support#svg-string-replacement-including-colors