Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to animate opacity in Xamarin.Forms

I wonder how to Animate opacity of elements visible on screen. For example for Entry I got to this:

this.Animate("", d =>
{
   Debug.WriteLine("anim:" + d);
   Username.Opacity = (AnimationTime - d) / AnimationTime;
}, 0, AnimationTime);

but I wonder if there is easier way. Unfortunately Animate method is poorly documented.

like image 448
Fishman Avatar asked Dec 29 '25 05:12

Fishman


1 Answers

Use the YourLabel.FadeTo() method. For example, if you define the opacity to 0 starting the app,

await MyLabel.FadeTo (1, 2000, Easing.Linear);

means : the animation (changing opacity here) will last for 2000 ms linearly passing from 0 to 1.

like image 83
Nicolas Bodin-Ripert Avatar answered Dec 31 '25 19:12

Nicolas Bodin-Ripert