Comments (8)
myanimation.json, is the lottie animation and the "images" subfolder in Assets contains the respectives images.
<forms:AnimationView
x:Name="AnimationView"
Animation="myanimation.json"
Loop="True"
AutoPlay="True"
IsFolderImagesAdded="True"
VerticalOptions="Center"
HorizontalOptions="Center"
HeightRequest="300" WidthRequest="300"/>
from lottiexamarin.
Hi. I have same problem. Please Help.
from lottiexamarin.
Hi @paradisehuman, I solved temporarily as follows:
- Install the Lottie platform nugget package on Android and iOS projects.
- In the PCL project, from this repository (Lottie.Forms) copy the file AnimationView.cs and aggregate this code:
public static readonly BindableProperty IsFolderImagesAddedProperty = BindableProperty.Create(nameof(IsFolderImagesAdded),
typeof(bool), typeof(AnimationView), default(bool));
public bool IsFolderImagesAdded
{
get { return (bool)GetValue(IsFolderImagesAddedProperty); }
set { SetValue(IsFolderImagesAddedProperty, value); }
}
- In Android and iOS projects add the correspondants files AnimationViewRenderer.cs, from Lotttie.Forms.Droid and Lottie.Forms.iOS.
- On Android add this code to the AnimationViewRenderer.cs file
OnElementChanged method
if (e.NewElement != null)
{
e.NewElement.OnPlay += OnPlay;
e.NewElement.OnPause += OnPause;
_animationView.Loop(e.NewElement.Loop);
if (!string.IsNullOrEmpty(e.NewElement.Animation))
{
_animationView.SetAnimation(e.NewElement.Animation);
Element.Duration = TimeSpan.FromMilliseconds(_animationView.Duration);
}
if (e.NewElement.IsFolderImagesAdded)
{
_animationView.SetImageAssetsFolder("images");
}
if (e.NewElement.AutoPlay)
{
_animationView.PlayAnimation();
}
}
OnElementPropertyChanged method
if (e.PropertyName == AnimationView.AnimationProperty.PropertyName)
{
_animationView.SetAnimation(Element.Animation);
Element.Duration = TimeSpan.FromMilliseconds(_animationView.Duration);
if (Element.IsFolderImagesAdded)
{
_animationView.SetImageAssetsFolder("images");
}
if (Element.AutoPlay)
{
_animationView.PlayAnimation();
}
}
- On iOS, I only add the images directly on the root of the project and is working.
- On the XAML file
<forms:AnimationView x:Name="AnimationView" Animation="animation.json" Loop="True" AutoPlay="True" IsFolderImagesAdded="True" VerticalOptions="Center" HorizontalOptions="Start" HeightRequest="150" WidthRequest="150"/>
I hope this can help you.
from lottiexamarin.
@golo98 Thank you for your help. But unfortunately a gray circle is showed me instead of the images. Where must be image folder in Android project ? In the root ? and what is the Images build action?
from lottiexamarin.
@paradisehuman, on android project, the lottie animation file and the images subfolder resides in the Assets folder, on the iOS project the lottie animation and the respectives images I put in the root project folder.
from lottiexamarin.
@golo98 I put Images in Assets folder and images build action is AndroidAssets and nothing has changed !
from lottiexamarin.
@golo98 My problem was solved. my after effect project had problem. I replace another project and it works like a charm. Thank you .
from lottiexamarin.
@martijn00 is there any reason we can't have an "ImagesFolderPath" property on the animation view itself?
from lottiexamarin.
Related Issues (20)
- Application crash on version 4.2.2 upgrade HOT 2
- XF.UWP crash when navigating back HOT 2
- XF.UWP support failing at version 4.1.0
- No native support for macOS/arm64
- Animation stopped working on Android HOT 3
- Replacement for OnPlayProgressSegment event?
- Using 4.1 in a Xamarin.Forms app when running on iOS an error ouccurs. HOT 3
- Support for .NET 6 HOT 12
- Xamarin iOS - animation scaling out of bounds
- Lottie nuget preventing other nugets from upgrading HOT 1
- IOS Animation happening too soon HOT 3
- Not able to Build Unit Test Project(.NET 6) in MAC referencing .net standard library(Xamarin Forms) which uses Lottie
- colors not showing on iOS when colors edited with lottie editor HOT 1
- Lottie with base64-encoded data
- iOS Not rendering animation after lottie editor color edit HOT 2
- Xamarin forms iOS Cannot access a disposed object HOT 1
- [Update binding iOS project] Support json files created with "Figma to Lottie"
- Dependency issue with Square.OkIO HOT 7
- AndroidX.Collection dependency error. HOT 4
- Need support of new privacy manifest file, Nuget package is too old
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lottiexamarin.