在中心旋转图像不顺畅(Monodroid)

Lie*_*tjj 5 android rotation xamarin.android

我有一个图像(看起来像一个圆形的加载圆圈)我想围绕它自己的中心旋转..我看到很多代码建议将PivotY和PivotX设置为0.5F或图像的一半.两者都不起作用.经过大量的反复试验,它确实围绕它自己的中心旋转,使用以下代码:

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);
Run Code Online (Sandbox Code Playgroud)

但是动画本身不再平滑,图像似乎旋转大约50度然后开始挂起并跳过旋转的一半然后继续正常在旋转的上半部分(我希望这没有任何意义).

知道为什么我的旋转不能平稳地旋转整个360度吗?

编辑

我还没有解决这个问题,但我确实发现了一些特殊的东西.动画在加载屏幕上使用,在动画时刻没有额外的功能.我注意到,当我将手指放在屏幕上时,动画会顺利发生!

这让我觉得这个问题可能不在动画代码中,而在于其他东西..但我还不知道......

Lie*_*tjj 5

我终于找到了答案!

我已经包括这条线:

loading.setDrawingCacheEnabled(true);
Run Code Online (Sandbox Code Playgroud)

之后不得不将枢轴改为0.5F.现在动画运行顺利!

//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);
Run Code Online (Sandbox Code Playgroud)