Giter VIP home page Giter VIP logo

Comments (8)

golo98 avatar golo98 commented on August 27, 2024 1

@paradisehuman

image

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"/>

On iOS
image

from lottiexamarin.

paradisehuman avatar paradisehuman commented on August 27, 2024

Hi. I have same problem. Please Help.

from lottiexamarin.

golo98 avatar golo98 commented on August 27, 2024

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.

paradisehuman avatar paradisehuman commented on August 27, 2024

@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.

golo98 avatar golo98 commented on August 27, 2024

@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.

paradisehuman avatar paradisehuman commented on August 27, 2024

@golo98 I put Images in Assets folder and images build action is AndroidAssets and nothing has changed !

from lottiexamarin.

paradisehuman avatar paradisehuman commented on August 27, 2024

@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.

mhmd-azeez avatar mhmd-azeez commented on August 27, 2024

@martijn00 is there any reason we can't have an "ImagesFolderPath" property on the animation view itself?

from lottiexamarin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.