I have an Image (which looks like a round loading circle) that I want to rotate around it's own center.. I saw a lot of code which suggested to set the PivotY and PivotX to 0.5F or th half of the image. Both does not work.. After a lot of trial and error it does rotate around it's own center with the following code:
ImageView loading = FindViewById<ImageView>(Resource.Id.loadingGif);
RotateAnimation rAnim = new RotateAnimation(0.0F, 359.0F, Dimension.RelativeToSelf, 0.25F, Dimension.RelativeToSelf, 0.25F);
rAnim.Interpolator = new LinearInterpolator();
rAnim.RepeatCount = Animation.Infinite;
rAnim.Duration = 1000;
loading.StartAnimation(rAnim);
But the animation itself is not going smooth anymore, the image seems to rotate about 50degrees then starts to hang and skips half of the rotation and then continues normally on the top half of the rotation (I hope that makes any sense).
Any idea why my rotation does not rotate the full 360 degrees smoothly?
EDIT
I still haven't solved this problem, but I did just discover something peculiar about it. The animation is used on a loading screen with no extra functionalities on the moment of the animation. I noticed that when I keep my finger on the screen the animation DOES happen smoothly!!
This got me thinking that the issue maybe isn't in the animation code but something else.. but what I don't know yet..
I've finally found the answer!
I've included the line:
loading.setDrawingCacheEnabled(true);
And after that had to change the pivots to 0.5F too. And now the animation runs smoothly!
//Rotate image
ImageView loading = FindViewById<ImageView>(Resource.Id.loadingGif);
loading.setDrawingCacheEnabled(true);
rAnim = new RotateAnimation(0.0F, 359.0F, Dimension.RelativeToSelf, 0.5F, Dimension.RelativeToSelf, 0.5F);
rAnim.Interpolator = new LinearInterpolator();
rAnim.RepeatCount = Animation.Infinite;
rAnim.Duration = 1500;
loading.StartAnimation(rAnim);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With