Achraf Ben Alaya
No Result
View All Result
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
    • General Tips & Fix
  • AI
  • Cloud
  • Motivation
  • Courses
  • About
    • Resume
    • Privacy Policy
SUBSCRIBE
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
    • General Tips & Fix
  • AI
  • Cloud
  • Motivation
  • Courses
  • About
    • Resume
    • Privacy Policy
No Result
View All Result
Achraf Ben Alaya
No Result
View All Result
ADVERTISEMENT
Home Blog

Animations with Lottie in Xamarin Forms

achraf by achraf
April 26, 2020
in Blog, xamarin
3 min read
0
Animations with Lottie in Xamarin Forms
0
SHARES
1.1k
VIEWS
Share on FacebookShare on Twitter

Animations with Lottie in Xamarin Forms

Days ago , I have been trying to add some animation to one of my applications ,and I was fascinated when I found Lottie .

First , what is Lottie ?

Lottie is a library, designed for iOS, Android and React Native, by Airbnb, that allows you to run animations. These animations are defined in a JSON file, containing all the details of colors, shapes, transforms and more. These JSON files are created by Adobe After Effects. However, many designers have been happy to share their works, and you can access pre-built animations at LottieFiles.

Now , for me , what is more amazing than animation , is “Featured animations from community” ! You know why people are awesome ! people contribute to Lottie Files everyday, and just now I have found new awesome animations that I will spend some time after writing this post to see if I may need one of them .

Let’s see what are we going to build ! For our demo application I didn’t only just use Lottie plugin but I also used another plugin called Rg.Plugins.Popup to present the animation in a more beautiful way . now let’s see the

Demo :

 

1 of 3
- +

Now As you can see , using some animations can make your app look prettier and the user can understand his actions more easily .

How to use Lottie and Popup ? As I said before , I used two plugins , Lottie and Rg.Plugins.Popup . First let’s start by adding Lottie plugin by simply installing it to our solution :

As you can see there is a lot of Lottie plugins , when using xamarin.forms you should focus on Com.Airbnb.Xamarin.Forms.Lottie , here I’m using the latest stable and available version 3.0.0 .

now all you need is to download an animation file , which is a json file from Lottie website :

and after that, you should put that file inside the Assets folder in android project and inside Resources folder in Ios project.

Now , simply , to use one of those files you need to add this bloc of code

<forms:AnimationView x:Name="AnimationView"
  IsPlaying="True"
   Animation="gift-box.json"
  Loop="True"
  AutoPlay="True"
  VerticalOptions="FillAndExpand"
  HorizontalOptions="FillAndExpand" />

You can then control the animation , such as AutoPlay,Loop and IsPlaying so you can control the behavior of your application . Just like that , we have created a simple animation that you can include inside any page inside your project. now , let’s install the Rg.Plugins.Popup :

At this time , the available version is 1.1.5.188 . now after installing the nuget , there is some more work to do . The plugin requires to be initialized. To use a PopupPage inside an application, each platform application must initialize the Rg.Plugins.Popup. This initialization step varies from a platform to another : Android : You need to add ” Rg.Plugins.Popup.Popup.Init(this, bundle);” as in the picture below

On iOS

 

and like that , we have prepared our environment to use our plugin . now we need to create a PopupPage (You can read more details about it in this link)

<?xml version="1.0" encoding="utf-8" ?>
            <pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
             xmlns:forms="clr-namespace:Lottie.Forms;assembly=Lottie.Forms"
                mc:Ignorable="d"
                x:Class="LottieListTest.Views.PopupPageSentEmail">
                <Frame CornerRadius="20" 
                 BackgroundColor="GhostWhite" 
                HorizontalOptions="CenterAndExpand" 
                VerticalOptions="CenterAndExpand"
                 x:Name="AnimationFrame">
                    <StackLayout Spacing="10">
                        <forms:AnimationView x:Name="AnimationView"
                            Animation="91-mailsent.json"
                            Loop="True"
                            AutoPlay="True"
                            WidthRequest="150" HeightRequest="150"
                            VerticalOptions="FillAndExpand"
                            HorizontalOptions="FillAndExpand" />
                       <Label Text="Sent!" HorizontalTextAlignment="Center"/>
                         </StackLayout>
                         </Frame>
                        </pages:PopupPage>

now , after creating the PopupPage , we need to call it from our main page

await PopupNavigation.PushAsync(new PopupPageSentEmail()); We have, at end, created a beautiful simple addition to our project that will make it look better .

You can find the whole project , with the apk file so you can test it on your android phone inside the project on github from this link. Sorry iOS users , I don’t have neither a Mac or Iphone .

https://github.com/achrafbenalaya/xamarinformsaniamtion/blob/master/LottieListTest/Imagesandapk/com.companyname.lottielisttest-Signed.apk

ShareTweet
Previous Post

Font Awesome ,Bootstrap and Material Font Icons For Xamarin.Forms

Next Post

Sql tips

Related Posts

AI

Model Context Protocol (MCP): The Future of AI Integration

April 21, 2025
133
Azure

Step-by-Step Guide: Azure Front Door + Storage Account Static Website + Custom Domain with Terraform

March 11, 2025
272
Network Security & Route Tables – Checking NSGs, route tables, and service endpoints for a targeted VNET or Subnet
Azure

Network Security & Route Tables – Checking NSGs, route tables, and service endpoints for a targeted VNET or Subnet

February 3, 2025
141
Understanding Generative AI and RAG Benefits
AI

Understanding Generative AI and RAG Benefits

January 12, 2025
98
Azure Communication Services Email Sending Simplified: From Setup to Execution and Monitoring
Azure

Azure Communication Services Email Sending Simplified: From Setup to Execution and Monitoring

December 8, 2024
1.6k
PowerShell Automation for Azure Networks: Detailed VNET and Subnet Analysis
Azure

PowerShell Automation for Azure Networks: Detailed VNET and Subnet Analysis

November 2, 2024
508
Next Post
Sql tips and tricks

Sql tips

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Terraform

Certifications

Microsoft certified trainer (MCT)

Recommended

Network Security & Route Tables – Checking NSGs, route tables, and service endpoints for a targeted VNET or Subnet

Network Security & Route Tables – Checking NSGs, route tables, and service endpoints for a targeted VNET or Subnet

February 3, 2025
141
Swagger & OpenAPI and Versioning for ASP.NET Core

Swagger & OpenAPI and Versioning for ASP.NET Core

December 8, 2020
1.5k
How to setup nginx reverse proxy for aspnet core apps with and without  Docker compose

How to setup nginx reverse proxy for aspnet core apps with and without Docker compose

November 23, 2022
1.9k
Azure Function to Upload Data to Azure Blob

Azure Function to Upload Data to Azure Blob

August 29, 2020
3.4k

From Docker Hub, switch to Azure Container Registry & AKS

January 16, 2023
520
Hello Microsoft Graph !

Hello Microsoft Graph !

February 25, 2021
526
Facebook Twitter LinkedIn Youtube

Model Context Protocol (MCP): The Future of AI Integration

April 21, 2025

Step-by-Step Guide: Azure Front Door + Storage Account Static Website + Custom Domain with Terraform

March 11, 2025
Network Security & Route Tables – Checking NSGs, route tables, and service endpoints for a targeted VNET or Subnet

Network Security & Route Tables – Checking NSGs, route tables, and service endpoints for a targeted VNET or Subnet

February 3, 2025

Categories

  • AI (2)
  • Apps (1)
  • Azure (63)
  • blazor (2)
  • Blog (91)
  • c# (7)
  • Cloud (65)
  • Courses (3)
  • Dapr (4)
  • docker (4)
  • Games (1)
  • General Tips & Fix (1)
  • Home (1)
  • Kubernetes Service (AKS) (1)
  • motivation (2)
  • Motivation (3)
  • News (9)
  • Resume (1)
  • sql (4)
  • Terrafrom (1)
  • Tricks, Tips and Fixes (4)
  • xamarin (5)
No Result
View All Result
  • Home
  • News
  • Blog
    • blazor
    • c#
    • Cloud
      • Azure
    • docker
    • sql
    • xamarin
    • Dapr
    • Tricks, Tips and Fixes
    • General Tips & Fix
  • AI
  • Cloud
  • Motivation
  • Courses
  • About
    • Resume
    • Privacy Policy