Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

SVG image is not displaying in android in xamarin.forms

Praveen.BPraveen.B INMember ✭✭
edited December 2018 in Xamarin.Forms

I am trying ti display the SVG image in my xamarin.form application, there are no issues to display the SVG image in iOS but not able to display the same image in the android application.

here is my code to display the svg image
<ContentView.Resources> <ResourceDictionary> <ffimageloadingsvg:SvgImageSourceConverter x:Key="SvgImageSourceConverter"></ffimageloadingsvg:SvgImageSourceConverter> </ResourceDictionary> </ContentView.Resources> <ContentView.Content> <ffimageloadingsvg:SvgCachedImage Source="{Binding SvgFileName, Converter={StaticResource SvgImageSourceConverter}}" Grid.Column="0" WidthRequest="200" HeightRequest="600" ReplaceStringMap="{Binding BodyMapreplceStrings}" /> </ContentView.Content>

And from View Model I am binding the image as following

 public string SvgFileName
        {
            get { return _svgFileName; }
            set
            {
                _svgFileName = value;
                OnPropertyChanged();
            }
        }

and

SvgFileName="Flower.svg";

and given svg image in Resources for iOS and in Resources ->drawable

in MainActivity added following lines
CachedImageRenderer.Init(true);
var ignore = typeof(SvgCachedImage);

Is there anything I am missing?

Answers

  • JuniorJiangJuniorJiang Member, Xamarin Team Xamurai

    Hi @Praveen.B , which way used to show SVG image. Do you refer to this link?

  • Praveen.BPraveen.B INMember ✭✭

    Thanks for the reference @JuniorJiang , I am using FFimageLoading for loading SVG images.

  • I had the similar issue and the cause was i had two files with same name but with different extension like 'demo.png' and 'demo.svg'; i don't know if u have similar cause but renaming the file solved my issue.

Sign In or Register to comment.