Center image rotation does not go smoothly (Monodroid)

I have an image (similar to a round boot circle) that I want to rotate around its own center. I saw a lot of code that suggested setting PivotY and PivotX to 0.5F or half the image, Both do not work. After a lot of trial and error, it revolves around its 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 ceases to be smooth, the image seems to rotate about 50 degrees, then it starts to freeze and skips half the rotation, and then continues normally in the upper half of the rotation (I hope this makes sense).

Any idea why my rotation doesn't rotate 360 ​​degrees exactly?

EDIT

I still have not solved this problem, but I just found something peculiar in it. Animation is used on the loading screen without additional functions at the time of animation. I noticed that when I hold my finger on the screen, the animation goes smoothly!

It made me think that the problem might not be in the animation code, but in something else .. but I still don't know.

+5
source share
1 answer

I finally found the answer!

I included the line:

loading.setDrawingCacheEnabled(true);

And after that I had to change the turns 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);
+4
source

All Articles