Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lottie.Forms - Load from EmbeddedResources

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?

like image 514
DirtyNative Avatar asked Nov 14 '18 19:11

DirtyNative


People also ask

How to programmatically load Lottie animation?

The simplest way to use it is with LottieAnimationView: Or you can load it programmatically in multiple ways. From a json asset in app/src/main/assets: This method will load the file and parse the animation in the background and asynchronously start rendering once completed.

What are the advantages of Lottie files?

One of its major advantages is that Lottie files are generally much smaller than an equivalent animated .gif file. For Xamarin.Forms, a Lottie implementation also exists and allows you to play beautiful animated JSON illustrations in your mobile apps. A Lottie open-source implementation also exists for Xamarin.Forms, and it is very easy to use.

Is there a Lottie for Xamarin forms?

For Xamarin.Forms, a Lottie implementation also exists and allows you to play beautiful animated JSON illustrations in your mobile apps. A Lottie open-source implementation also exists for Xamarin.Forms, and it is very easy to use.

Where are the JSON files for Lottie samples?

The JSON files for them are located in LottieSample/src/main/assets and the original After Effects files are located in /After Effects Samples The sample app can also load json files at a given url or locally on your device (like Downloads or on your sdcard). Contributors are more than welcome.


1 Answers

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;
like image 83
Emad Younan Avatar answered Sep 20 '22 12:09

Emad Younan