1

I have used Animation() method to make my view with the animation of scaling and Rotation. With the Rotation based on the Y axis, the default height and width of my view has been changed. It looks like the parallelogram.

rotation of rectangle along y-axis transformed to a parallelogram.

 myview.Animate().RotationY(rotationangle)
                        .X(xposition)
                        .SetDuration(mduration)
                        .WithLayer()
                        .SetInterpolator(interpolate).Start();

My requirement:

I just want the rotation of my view no need to change its projection. How to restrict the rotation of rectangle along y-axis transformed to a parallelogram.

For more reference, please check the attached sample

now view be like,

Image

Please share your idea.

Thanks in Advance.

Note: while using PivotX and PivotY, there is no parallelogram shape. But I don't know the exact usage of that.

Regards,

Hemalatha Marikumar

2 Answers2

0

is that not what are you looking for ?

it may work if you put this code in your current activity Android: Temporarily disable orientation changes in an Activity

0

Do you want to create a 2D rotation?
You could try to use ScaleAnimation to rotate the view. If you want to rotate 360 degrees, you could use AnimationListener.
For example:

            Button myview = (Button)FindViewById(Resource.Id.button2);
            ScaleAnimation scaleAnimation = new ScaleAnimation(1, 0, 1, 1,
            Android.Views.Animations.Dimension.RelativeToParent, 0.5f, Android.Views.Animations.Dimension.RelativeToParent, 0.5f);
            ScaleAnimation scaleAnimation2 = new ScaleAnimation(0, 1, 1, 1,
            Android.Views.Animations.Dimension.RelativeToParent, 0.5f, Android.Views.Animations.Dimension.RelativeToParent, 0.5f);
            scaleAnimation.Duration = 4000;
            scaleAnimation.SetAnimationListener(new AnimationListener(myview, scaleAnimation2));
            scaleAnimation2.Duration = 4000;
            myview.StartAnimation(scaleAnimation);

The Listener:

        public class AnimationListener :Java.Lang.Object, IAnimationListener 
        {
            View view;
            Animation animation2;
            public AnimationListener(View view, Animation animation)
            {
                this.view = view;
                this.animation2 = animation;
            }

            public void OnAnimationEnd(Animation animation)
            {
                view.StartAnimation(animation2);
            }

            public void OnAnimationRepeat(Animation animation)
            {

            }

            public void OnAnimationStart(Animation animation)
            {

            }
        }
Billy Liu - MSFT
  • 2,168
  • 1
  • 8
  • 15