Xamarin.Forms animations
Xamarin.Forms
has multiple functions for animating views. We have access to the following functions:
FadeTo
: This is used to animate opacity (that is, fade in/out).RotateTo
: This is used to animate rotations.ScaleTo
: This is used to animate size.TranslateTo
: This is used to animate (x, y) positions.LayoutTo
: This is used to animate x, y, width, and height.
Tip
Stay away from the LayoutTo
function. Jason Smith (the creator of Xamarin.Forms
) recommends you stick with the TranslateTo
instead. The issue with LayoutTo
is the parent of the view you are calling LayoutTo
on will not be aware of the translation/resize that happened and will simply overwrite it at the next layout cycle (like when you rotate the device). This is because LayoutTo
is calling the same method Layouts call to position children.
We are now going to use a few of these animation functions to animate our target image when a use touches to focus. The AnimateFocalTarget
function will be responsible for performing...