简体   繁体   English

在 xamarin.forms 中应用动画

[英]Applying animation in xamarin.forms

有什么方法可以在 Xamarin.forms 中实现像https://codemyui.com/circular-water-fill-loading-animation/这样的动画?

Is there any way I can implement the animation like ...有什么方法可以实现动画,例如...

The short answer is;简短的回答是; Yes.是的。

The longer answer;更长的答案; It depends upon what you really need, only you can answer that.这取决于您真正需要什么,只有您可以回答。

A "quick way" (at least for me) is to use the Xamarin.Forms' WebView and embed the html/svg/css/JScript into native application projects and setup a javascript interface to control the percentage completion (the water.style.transform element). “快速方法”(至少对我而言)是使用 Xamarin.Forms 的WebView并将 html/svg/css/JScript 嵌入到本机应用程序项目中,并设置一个 javascript 界面来控制完成百分比( water.style.transform元素)。

You could, of course, re-implement it using something like SkiaSharp, Lottie, etc and create a cross-platform Forms' control, or implement it as a "native" control on each platform.当然,您可以使用 SkiaSharp、Lottie 等工具重新实现它,并创建一个跨平台的 Forms 控件,或者将其实现为每个平台上的“本机”控件。

Note: I'm a big fan of Lottie and would personally take that approach, but they do not support native UWP.注意:我是 Lottie 的忠实粉丝并且会亲自采取这种方法,但他们不支持原生 UWP。 Currently supported is iOS, Android, Web.目前支持 iOS、Android、Web。

I edited the colors, etc. on that PEN sample you linked to and added the html/js/css to a Forms' solution, setup a JS interface and the results work in a Forms' WebView (iOS' UIWebView and Android's WebView, did not test UWP Edge, but it should work fine):我在您链接的 PEN 示例上编辑了颜色等,并将 html/js/css 添加到 Forms 的解决方案中,设置了 JS 界面,结果在 Forms 的 WebView(iOS 的 UIWebView 和 Android 的 WebView,不测试 UWP Edge,但它应该可以正常工作):

在此处输入图片说明

The Lottie is my preferred, but you can use a animation with the Nuget XamAnimation. Lottie 是我的首选,但您可以将动画与 Nuget XamAnimation 一起使用。 It most hard to create but it's so good too.它最难创造,但它也很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM