【发布时间】:2013-06-10 16:34:20
【问题描述】:
我正在尝试开发我的第一个 Android 应用。我读了很多关于动画的文章。现在我的布局上有一个 ImageView,我想将它旋转 360 度。这个动画永远重复。所以这是我的 solteypanim.xml 文件:
<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>
这是我的活动代码
@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();
...
}
它工作正常,但有一个问题。 rotation 值的变化不是线性的。我的意思是在动画的开始和结束时有一个缓动效果。它开始缓慢,然后加快速度,然后降低速度。每一回合都有同样的问题。
您能告诉我如何禁用此缓动效果吗?
【问题讨论】:
-
为动画设置LinearInterpoator。
-
@user117 ,它已经设置好了。查看 xml 文件的第 2 行。