コード例 #1
0
        private void SecondSolution()
        {
            //Similar to first solution but uses a Spring Animator.

            VectorDrawable avd = (VectorDrawable)this.GetDrawable(Resource.Drawable.Needle);

            rotateAnim = new SpringAnimation(secondSolution, DynamicAnimation.Rotation, 270);
            rotateAnim.Spring.SetStiffness(SpringForce.StiffnessLow);
            rotateAnim.SetStartVelocity(50);
            secondSolution.SetImageDrawable(avd);
        }
コード例 #2
0
        public static Bitmap ToBitmap(this VectorDrawable vectorDrawable, int?width = null, int?height = null)
        {
            var bitmap = Bitmap.CreateBitmap(
                width ?? vectorDrawable.IntrinsicWidth,
                height ?? vectorDrawable.IntrinsicHeight,
                Bitmap.Config.Argb8888);
            var canvas = new Canvas(bitmap);

            vectorDrawable.SetBounds(0, 0, canvas.Width, canvas.Height);
            vectorDrawable.Draw(canvas);
            return(bitmap);
        }
コード例 #3
0
        private void NotWorking()
        {
            // This does not create an animation. Is it not possible to animate a vector drawable in code?
            // Am I missing a step here?

            VectorDrawable avd = (VectorDrawable)this.GetDrawable(Resource.Drawable.Needle);

            idealSolution.SetImageDrawable(avd);

            var rotate = ObjectAnimator.OfFloat(avd, "rotation", 0f, 756f).SetDuration(3000);

            notWorking = new AnimatorSet();
            notWorking.SetInterpolator(new AccelerateDecelerateInterpolator());
            notWorking.Play(rotate).With(ObjectAnimator.OfFloat(avd, "pivotX", 13.22f)).With(ObjectAnimator.OfFloat(rotate, "pivotY", 13.22f));
        }