/** * Toogle the play/pause status * * @param withAnim false to change status without animation */ public void Toggle(bool withAnim) { if (withAnim) { if (mAnimatorSet != null) { mAnimatorSet.Cancel(); } mAnimatorSet = new AnimatorSet(); bool isPlay = mDrawable.IsPlay(); ObjectAnimator colorAnim = ObjectAnimator.OfInt(this, "color", isPlay ? mPauseBackgroundColor : mPlayBackgroundColor); colorAnim.SetEvaluator(new ArgbEvaluator()); Animator pausePlayAnim = mDrawable.GetPausePlayAnimator(); mAnimatorSet.SetInterpolator(new DecelerateInterpolator()); mAnimatorSet.SetDuration(PlayPauseAnimationDuration); mAnimatorSet.PlayTogether(colorAnim, pausePlayAnim); mAnimatorSet.Start(); } else { bool isPlay = mDrawable.IsPlay(); InitStatus(!isPlay); Invalidate(); } }
protected override void OnElementChanged(ElementChangedEventArgs <Button> e) { base.OnElementChanged(e); if (e.NewElement != null) { _textColorChangingAnimation = ObjectAnimator.OfInt(this.Control, "textColor", Color.Red.ToAndroid(), Color.Blue.ToAndroid()); _textColorChangingAnimation.SetDuration(1000); _textColorChangingAnimation.SetEvaluator(new ArgbEvaluator()); _textColorChangingAnimation.RepeatCount = ValueAnimator.Infinite; _textColorChangingAnimation.RepeatMode = ValueAnimatorRepeatMode.Reverse; ((AnimatingTextColorButton)e.NewElement).PropertyChanged += AnimatingTextColorButton_PropertyChanged; if (((AnimatingTextColorButton)e.NewElement).IsTextColorAnimating) { StartTextColorAnimation(); } } if (e.OldElement != null) { ((AnimatingTextColorButton)e.OldElement).PropertyChanged -= AnimatingTextColorButton_PropertyChanged; } }
private static void WonAnimation(Java.Lang.Object value) { cntRepeat = 0; ObjectAnimator colorAnim = ObjectAnimator.OfInt(value, "textColor", Color.White, Color.Transparent); colorAnim.SetDuration(800); colorAnim.SetEvaluator(new ArgbEvaluator()); colorAnim.RepeatCount = 3; colorAnim.RepeatMode = ValueAnimatorRepeatMode.Reverse; colorAnim.Start(); BlockButton(); colorAnim.AnimationEnd += ColorAnim_AnimationEnd; }