On my Xamarin.Forms 项目,我想显示一个洛蒂动画 during API调用或期间加载网站 in a WebView
.
为此,我限制了IsVisible
的财产洛蒂动画 to the IsBusy
我的财产视图模型: 这个效果很好。
<lottie:AnimationView Animation="resource://lottie_loading.json?assembly=MyApp"
AnimationSource="EmbeddedResource"
BackgroundColor="Transparent"
AutoPlay="True"
RepeatMode="Infinite"
IsVisible="{Binding IsBusy}">
但是加载时间有时很短,所以我想找到一种方法在隐藏之前完整显示 Lottie 动画一次.
是否可以?实现这一目标的更好方法是什么?
我想在期间显示 Lottie 动画API调用
public async void loadData()
{
//Data load started
viewModel.IsBusy = true;
await methodOfLoadingData...;
//Data load finished
viewModel.IsBusy = false;
}
在WebView中加载网站期间:
private void MyWebView_Navigating(object sender, WebNavigatingEventArgs e)
{
viewModel.IsBusy = true;
}
private void MyWebView_Navigated(object sender, WebNavigatedEventArgs e)
{
viewModel.IsBusy = false;
}
但加载时间有时很短
加载持续时间取决于您完全加载数据/webview 的时间。如果加载数据/webview 的速度非常快,则加载持续时间应该很短。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)