Monday 30 October 2017

Xamarin.Forms Animation


Hello friends animation is a great way to help you make your app even more attractive and smoother.
Note that there is no XAML interface for the Xamarin.Forms animation classes. However, animations can be encapsulated in behaviors and then referenced from XAML.
The ViewExtensions class provides the following extension methods that can be used to create simple animations
  • TranslateTo animates the TranslationX and TranslationY properties of a VisualElement.
  • ScaleTo animates the Scale property of a VisualElement.
  • RotateTo animates the Rotation property of a VisualElement.
  • RotateXTo animates the RotationX property of a VisualElement.
  • RotateYTo animates the RotationY property of a VisualElement.
  • FadeTo animates the Opacity property of a VisualElement.

Simple Animations

Each extension method in the ViewExtensions implements a single animation operation that progressively changes a property from one value to another value over a period of time.

Scalling

The scale method increases or decreases the size of an element (according to the parameters given for the width and height). Scaling refers to the resizing of a element.Scaling is used to change the visual appearance of an image, to alter the quantity of information stored in a scene representation, or as a low-level preprocessor in multi-stage image processing chain which operates on features of a particular scale.
await image.ScaleTo (2, 2000);

Rotation

A rotation is a circular movement of an object around a center (or point) of rotation.
The rotate method rotates an element clockwise or counter-clockwise according to a given degree.
await image.RotateTo (360, 2000);

Translation

The translate method moves an element from its current position (according to the parameters given for the X-axis or TranslationX and the Y-axis or TranslationY).
await image.TranslateTo (-100, -100, 1000);

Fading

There is no property such as transparency. But, you can achieve transparency by inserting a pseudo element with regular opacity the exact size of the element behind it. The opacity-level describes the transparency-level, it ranges from 0.0 to 1.0. The level 0.0 is completely transparent, 0.5 is 50% see-through and level 1.0 is not transparent. Opacity has a default initial value of 1 (100% opaque).
The opacity property specifies the opacity/transparency of an element. The opacity property can take a value from 0.0 - 1.0.
image.Opacity = 0;
await image.FadeTo (1, 4000);

Compound Animations

A compound animation is a sequential combination of animations, and can be created with the await operator.

Composite Animations

A composite animation is a combination of animations where two or more animations run simultaneously. Composite animations can be created by mixing awaited and non-awaited animations.
await Task.WhenAll (
  image.RotateTo (307 * 360, 2000),
  image.RotateXTo (251 * 360, 2000),
  image.RotateYTo (199 * 360, 2000)
);

Canceling Animations

An application can cancel one or more animations with a call to the static ViewExtensions.CancelAnimations method.
ViewExtensions.CancelAnimations (image);

Let`s Start Animation Demo
Create a XAML and design:

Now we write c# code:

TADDA !

Animation In Android

 

Tuesday 24 October 2017

Xamarin Forms Lottie Animations


What is Lottie ?

Lottie is an iOS, Android, and Xamarin.Forms Native library that renders After Effects animations in real time,allowing apps to use animations as easily as they use static images with the Json file.

Why Lottie?

  • This tool or library is very effective and flexible to use.
  • Make your animation efficient in any way.
  • Small Jason File Size.
  • To use the Lite Library is terrible and easy, now also available on Xamarin form. Below I'm  mentioned important URL To check the Git Repository, I want to very thank Martijn van Dijk
  • https://github.com/martijn00/LottieXamarin 
NuGet package:https://www.nuget.org/packages/Com.Airbnb.Xamarin.Forms.Lottie/2.3.4

Available on NuGet! 

Install-Package Com.Airbnb.Xamarin.Forms.Lottie -Version 2.3.4 

Now i am Install the Lottie Package in all your projects:
 
Here initialize Lottie plugin in both project Android(In MainActivity) and Ios(In AppDelegate) using AnimationViewRenderer.Init(); 
you initialize Lottie plugin in Android Project in MainActivity.

you initialize Lottie plugin in Ios Project AppDelegate.

Now we use json, if you don’t have one you can choose  JSON file from here:https://www.lottiefiles.com/

Now you add json in iOS  project and make sure you have the build action in Bundle Resource
select animation json and right, click then click on property.



In Android, add your json and make sure you have the build action in Android Asset.
select animation json and right click, then click on the property. 


Now we write code in xaml and Add the reference  

xmlns:forms=“clr-namespace:Lottie.Forms;assembly=Lottie.Forms“



TADAA!,
you should have your animation working!!

 
Lottie Animation In Android

  Click Here to Complete Source
Lottie Animation in Ios

Click Here to Complete Source Code

Saturday 21 October 2017

Xamarin.Forms Floating Action Button

Xamarin.Forms Floating Action Button

Hello Xamarians,

This is my first post and I do not know how much better it will be for other people. If I see some mistake then please let me know that.
In this, I am talking about FloatingActionButton or “FAB” from how we can use xamarin forms with the help of the plugin.

Now Available on NuGet!

Install-Package FAB.Forms -Version 2.2.0-pre1  

Install the NuGet package and then you we include it in your XAML or call it from C#.

 Here is some code behind c# code:

Android Example:

 

Ios Example:

 

Make it more flexible

if you want to add different type of Background color in FAB so you can use NormalColor="Green" property.
you can Adjust Height and Width with the using of HeightRequest="90"    
WidthRequest="90"
And showing Shadow to use HasShadow="True" and etc.

Featured Post

Sliding Entry In Xamarin.Forms

  Today, I am going to show you how to create a Custom Slide entry in Xamarin.Forms with animation and also using gradient color. here is Y...