Search code examples
xamarinlottie

How to play lottie starting at the end, playing backwards to the start of the animation in xamarin?


Is there any option to play lottie starting at the end, playing backwards to the start of the animation in xamarin? From code behind in c#

<lottie:AnimationView x:Name="lottie" AutoPlay="False" Animation="heartreaction.json"  />

Clicked

private void super_Clicked(object sender, EventArgs e)
    {
        lottie.PlayAnimation();
        //Instead play it backwards
    }

Solution

  • If you use SKLottieView, you could set RepeatMode="Reverse" to make it. You could add Skiasharp.Extended.UI.Forms Nuget first.

    The following code is an example:

    <skia:SKLottieView 
        HorizontalOptions="CenterAndExpand"
        VerticalOptions="CenterAndExpand"
        x:Name="myanimatedview"
        Source="dotnetbot.json"
        HeightRequest="300"
        WidthRequest="300"
        RepeatCount="-1"
        IsAnimationEnabled="True"
        RepeatMode="Reverse"/>
    

    Or set it in code behind cs file:

    myanimatedview.RepeatMode = SKLottieRepeatMode.Reverse;
    

    Hope it works for you.