Lottie animation bindings for Xamarin.Forms has been out for quite a while now. Yet I see a lot of people out there who don't use a powerful feature to share animation files across platforms rather than manually *copy/paste*ing them into platform projects.
Sharing your resources has never been easier with Xamarin.Forms nowadays. Let's see how you can have a single point where you keep all your Lottie Animation files.
Build Actionfor the JSON file MUST be
- Let's add the animationView to a page and point the animations Source to the very
EmbeddedResourcewe added earlier.
<?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:lottie="clr-namespace:Lottie.Forms;assembly=Lottie.Forms" x:Class="ayah.Views.MyPage"> <Grid> <lottie:AnimationView AnimationSource="EmbeddedResource" Animation="Resources.loading.json" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" RepeatMode="Infinite"/> </Grid> </ContentPage>
AnimationSourceproperty is set to