14

I've got a AnimationView defined in AirBnb's Lottie Framework which should load a file placed inside my Resource folder inside my Xamarin.Forms Project (the portable one)

        <forms:AnimationView
            x:Name="AnimationView"
            Animation="SharpLibrary.Forms.Assets.Images.WineGlass.json"
            Loop="True"
            AutoPlay="True"
            VerticalOptions="FillAndExpand"
            HorizontalOptions="FillAndExpand" />

But it seems it cannot resolve the string in Animation property, so it will not display the animation. If I place the file into the Resource folder and say Animation="WineGlass.json" it works.

Is there a way to load it from EmbeddedResource, or is this not possible?

DirtyNative
  • 2,553
  • 2
  • 33
  • 58
  • Did you try just use the animation name without the path and the extension? like `Animation="WineGlass"` – FabriBertani Nov 14 '18 at 19:23
  • I tried it now, but still doesn't show anything – DirtyNative Nov 14 '18 at 19:25
  • Animation Property loads the file from Platform Specific Asset not from your Portable one. You can check out the implementation details here https://github.com/martijn00/LottieXamarin/blob/develop/Lottie.Forms/Platforms/Ios/AnimationViewRenderer.cs – N Subedi Nov 14 '18 at 19:27
  • Okay, and is there a way to make it load from portable ones? – DirtyNative Nov 14 '18 at 19:28
  • Did you try to recreate the .json file in the correct directory of the specific project using Stream based on the shared project file? – Filipe Piletti Plucenio Jun 10 '20 at 21:21
  • @FilipePilettiPlucenio it only work when in platform resource folder, tried everything but it doesn't load from shared resource but there is one option, if I can generate NsUrl from the shared file then I can override it. – Shubham Jun 11 '20 at 20:46

1 Answers1

1

It worked with me at first you can put the json file at folder if you would or at the shared one

I put at folder renamed Image

Animation="Images.loading.json"

at the c# code put that

    animationView.AnimationSource = AnimationSource.EmbeddedResource;