旋转图像的中心不会顺利(Monodroid) [英] Rotate image on center not going smooth (Monodroid)

查看:139
本文介绍了旋转图像的中心不会顺利(Monodroid)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个形象(这看起来像一个圆形装载圈),我想围绕它自己的中心旋转。我看到很多code这表明该PivotY和PivotX设置为0.5F或日半图像。这两个不起作用..大量的试验后和错误它并围绕它自己的中心与以下code旋转:

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);

但动画本身不会平稳了,图像似乎绕50degrees然后开始挂并跳过一半的旋转,然后在旋转的上半部分,通常继续(希望使任何意义)。

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).

任何想法,为什么我转不转了360度平稳?

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!!

这让我思考这个问题也许不在动画code,但别的东西..但我还不知道是什么。

This got me thinking that the issue maybe isn't in the animation code but something else.. but what I don't know yet..

推荐答案

我终于找到了答案!

我已经包含行:

loading.setDrawingCacheEnabled(true);

在这之后,不得不改变支点来0.5F过。而现在的动画运行顺畅!

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);

这篇关于旋转图像的中心不会顺利(Monodroid)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆