private void PlayAnimation()
		{
			var animator = ObjectAnimator.OfFloat (this, "animationSeek", 0.0f, 1.0f);
			var animatorSet = new AnimatorSet ();
			animatorSet.SetDuration (AnimationDuration);
			animatorSet.SetInterpolator (new DecelerateInterpolator ());
			animatorSet.SetTarget (this);
            animatorSet.Play(animator);
			animatorSet.Start();
		}
Beispiel #2
0
        private AnimatorSet GetAnimatorSet(int idx, bool expand)
        {
            AnimatorSet set = null;
            var avgRadians = this.ToRadians(360 / (this.ChildCount - 1));
            var w = Math.Min(this.MeasuredWidth, this.MeasuredHeight) / 2;

            var cx = this.MeasuredWidth / 2;
            var cy = this.MeasuredHeight / 2;

            var c = this.GetChildAt(idx);
            var radians = idx * avgRadians;
            var hw = c.MeasuredWidth / 2;
            var hy = c.MeasuredHeight / 2;

            var tmp = (w - hw);
            var l = w + (int)Math.Round(tmp * Math.Cos(radians) - hw);
            var t = w + (int)Math.Round(tmp * Math.Sin(radians) - hw);

            var duration = new Random(1000).Next(200, 1000);

            set = new AnimatorSet();
            set.SetInterpolator(new Android.Views.Animations.BounceInterpolator());
            set.SetTarget(c);
            set.SetDuration(200 * idx + duration);
            //set.SetDuration(200);

            float[] xs = new float[] { cx - hw, l };
            float[] ys = new float[] { cy - hy, t };
            float[] ss = new float[] { 0.1f, 1 };
            if (!expand) {
                Array.Reverse(xs);
                Array.Reverse(ys);
                Array.Reverse(ss);
            }

            var aniX = ObjectAnimator.OfFloat(c, "X", xs);
            var aniY = ObjectAnimator.OfFloat(c, "Y", ys);
            var aniSX = ObjectAnimator.OfFloat(c, "ScaleX", ss);
            var aniSY = ObjectAnimator.OfFloat(c, "ScaleY", ss);

            aniX.SetAutoCancel(true);
            aniY.SetAutoCancel(true);
            aniSX.SetAutoCancel(true);
            aniSY.SetAutoCancel(true);

            set.PlayTogether(aniX, aniY, aniSX, aniSY);
            set.AnimationEnd += Set_AnimationEnd;

            return set;
        }