为什么会出现放宽对我旋转的动画效果? [英] Why there is easing effect on my rotating animation?

查看:234
本文介绍了为什么会出现放宽对我旋转的动画效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发展我的第一个Android应用程序。我读了很多文章关于动画。现在有我的布局的ImageView,我想将其旋转360度。而这个动画永远重复。因此,这里是我的solteypanim.xml文件:

I'm trying to develop my first Android app. I read a lots of article about animations. Now there is a ImageView on my layout and i want to rotate it 360 degrees. And this animation repeat forever. So here is my solteypanim.xml file :

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    android:ordering="sequentially" >
    <objectAnimator
    android:duration="3000"
        android:propertyName="rotation"
        android:repeatCount="infinite"
        android:valueTo="360"
        android:valueFrom="0" />
</set>

这是我的活动code

And this is my activity code

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    ...    
    ImageView solTeyp = (ImageView)findViewById(R.id.solTeyp);
    AnimatorSet solTeypAnim = (AnimatorSet) AnimatorInflater.loadAnimator(this, R.animator.solteypanim);
    solTeypAnim.setTarget(solTeyp);
    solTeypAnim.start();
    ...
    }

它的工作,但有一个问题。改变的旋转的的价值不是线性的。我的意思是在启动和动画结束一个缓和的作用。它开始慢慢地,然后获得速度,降低速度。没有为动辄同样的问题。

It's working BUT there is a problem. Changing of rotation's value not linear. I mean there is a easing effect at start and end of animation. It's starting slowly, and then getting speed, and decreasing speed. There is same problem for every turn.

你能告诉我如何可以禁用这个缓动效果?

Can you tell me how can i disable this easing effect ?

推荐答案

OK刚刚找到答案。我应该线性内插器设置为我的 objectAnimator ,不是我的设置

OK just found answer. I should set linear interpolator to my objectAnimator , not my set .

这样的:

<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:ordering="sequentially" >
    <objectAnimator
    android:duration="3000"
    android:interpolator="@android:anim/linear_interpolator"
        android:propertyName="rotation"
        android:repeatCount="infinite"
        android:valueTo="360"
        android:valueFrom="0" />
</set>

这篇关于为什么会出现放宽对我旋转的动画效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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