Lottie.Forms - Load from EmbeddedResources
Asked Answered
P

1

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?

Prepuce answered 14/11, 2018 at 19:14 Comment(6)
Did you try just use the animation name without the path and the extension? like Animation="WineGlass"Circumstance
I tried it now, but still doesn't show anythingPrepuce
Animation Property loads the file from Platform Specific Asset not from your Portable one. You can check out the implementation details here github.com/martijn00/LottieXamarin/blob/develop/Lottie.Forms/…Suzette
Okay, and is there a way to make it load from portable ones?Prepuce
Did you try to recreate the .json file in the correct directory of the specific project using Stream based on the shared project file?Trulatrull
@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.Kremlin
A
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;
Anestassia answered 10/10, 2020 at 20:47 Comment(1)
This was added in newer version, anyways tha ks for the answer :)Kremlin

© 2022 - 2024 — McMap. All rights reserved.