The animations I use are pretty basic:
- On Android:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var animationFadeOut = new AlphaAnimation(1.0f, 0.0f); | |
animationFadeOut.Duration = 200; | |
animationFadeOut.AnimationEnd += (sender, args) => | |
{ | |
base.Text = value; | |
var animationFadeIn = new AlphaAnimation(0.0f, 1.0f); | |
animationFadeIn.Duration = 200; | |
this.Animation = animationFadeIn; | |
}; | |
this.Animation = animationFadeOut; |
- On iOS:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIView.Animate( | |
0.25, | |
() => | |
{ | |
Alpha = 0; | |
}, | |
() => | |
{ | |
Text = value; | |
UIView.Animate(0.25, | |
() => | |
{ | |
Alpha = 1.0f; | |
}); | |
}); |
- On Windows:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var animation = new DoubleAnimation(); | |
animation.From = 1; | |
animation.To = 0; | |
animation.Duration = new Duration(TimeSpan.FromMilliseconds(200)); | |
animation.Completed += (sender, args) => | |
{ | |
control.TheTextBlock.Text = newText; | |
var fadeInAnimation = new DoubleAnimation(); | |
fadeInAnimation.From = 0.0; | |
fadeInAnimation.To = 1.0; | |
fadeInAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(200)); | |
Storyboard.SetTarget(fadeInAnimation, control); | |
Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath("Opacity")); | |
var storyboard2 = new Storyboard(); | |
storyboard2.Children.Add(fadeInAnimation); | |
storyboard2.Begin(); | |
}; | |
Storyboard.SetTarget(animation, control); | |
Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity")); | |
var storyboard = new Storyboard(); | |
storyboard.Children.Add(animation); | |
storyboard.Begin(); |
The video:
The source is available on: https://github.com/slodge/NPlus1DaysOfMvvmCross/tree/master/N-33-AnimateTextChanges
For a full and lovely index of N+1, see:
Where have you gone, Stuart?
ReplyDeleteNot far away. Still doing lots of .Net, but not so much mobile at the moment. Busy writing code, riding bikes and causing trouble :) Loving that Mvx has a life of its own (and a very good one too!)
Delete