Lottie Animation没有出现在Android设备上-Xamarin Forms

Lottie Animation没有出现在Android设备上-Xamarin Forms

问题描述:

我正在使用VS 2019 xamarin Forms,最近我观看了一些有关如何使用抽奖动画的视频,而且看起来非常简单.我正在做每一个步骤,但是当我运行该应用程序时,动画永远不会出现.

I'm using VS 2019 xamarin Forms, I recently watched some videos about how to use lottie animations and looks pretty simple. I'm doing every step but when I run the app the animation never appears.

Package Com.Airbnb.Lottie.Forms已添加到所有应用程序项目中(它是跨平台的)然后将Com.Airbnb.Android.Lottie添加到Android应用程序中(首先,我尝试不使用它,也无法正常工作)

Package Com.Airbnb.Lottie.Forms was added to all app projects (it's crossplatform) Then added Com.Airbnb.Android.Lottie to the Android app (first I tried without it, didn't work either)

这是代码

<?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="AppWasher.MainPage">

    <StackLayout>
  
        <lottie:AnimationView
            x:Name="animationView"
            Animation="26617-ogad.json"
            RepeatMode="Restart"
            VerticalOptions="FillAndExpand"
            HorizontalOptions="FillAndExpand"
            WidthRequest="300"
            HeightRequest="300"/>
        
    </StackLayout>

</ContentPage>

这是乐透提供的指南

<forms:AnimationView
    x:Name="animationView"
    Animation="LottieLogo1.json"
    AnimationSource="AssetOrBundle"
    Command="{Binding ClickCommand}"
    RepeatCount="3"
    RepeatMode="Restart"
    VerticalOptions="FillAndExpand"
    HorizontalOptions="FillAndExpand" />

我也尝试使用所有这些属性,结果相同.

I tried using all those properties too, same result.

我正在Android 9.0版上进行测试

I'm testing on Android 9.0 version

还将json文件添加到android项目中的assets文件夹中,并将构建操作设置为AndroidAsset

Also json files were added to the assets folder in the android project and build action is set to AndroidAsset

在我将android Target Framework 版本更改为 Android 10.0 后,它对我有用.

It works for me after i change the android Target Framework version to Android 10.0.

我发现最新的Lottie nuget依赖于 AndroidX .

And i found the latest Lottie nuget depends on AndroidX.