我创建了一个内容视图,在这个内容视图中,我插入了一个lottie动画:
我正在尝试将其设置为通用动画视图,以便可以将其用于多个异步任务。
加载动画.xaml
<?xml version="1.0" encoding="UTF-8"?>
<ContentView 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="Fit_Plans.Views.Common.LoadingAnimation">
<ContentView.Content>
<StackLayout>
<lottie:AnimationView
Grid.Column="0"
Margin="-20"
x:Name="LoadingAnimationView"
Animation="loading_animation.json"
AutoPlay="false"
HeightRequest="160"
WidthRequest="160"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand"/>
</StackLayout>
</ContentView.Content>
</ContentView>
现在在my someview.xaml.cs中
async protected override void OnAppearing()
{
Product produits = new Product();
if(getListProduit ==null || getListProduit.Count<=0)
{
getListProduit = await produits.loadMenuAsync(api, siteUrl);
PopulateProductsLists(getListProduit);
}
base.OnAppearing();
}
您可以注意到我有一个等待异步任务:
getListProduit = await produits.loadMenuAsync(api, siteUrl);
是否可以让我的lottie动画弹出animation.jason,当任务完成时关闭弹出窗口?或者,做这种事最好的方法是什么?