Skip to content

Programmatically Create SKLottieView in MAUI #157

@heiser

Description

@heiser

All of the examples I have seen assign the source in XAML; I have tried to do it in code without success:

            var source = new SKFileLottieImageSource()
            { 
                File = String.Format("{0}.json", Name)
            };
            
            var view = new SKLottieView()
            {
                Source = source,
                WidthRequest = 400,
                HeightRequest = 400,
                BackgroundColor = Colors.Red,
                RepeatMode = SKLottieRepeatMode.Restart,
                RepeatCount = Loop ? -1 : 0,
                //Scale = Scale,
                StyleId = ID
            };

The view renders to the screen but the animation does not appear.

I see in the source that the file is ultimately loaded using FileSystem.OpenAppPackageFileAsync and so I tested that with the file path I used in SKFileLottieImageSource, and it worked.

Also, I know the Lottie file I am using works, as it did fine in the Xamarin Forms app that we are attempting to migrate to MAUI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions