Easing effect for rotate animation in android

こ雲淡風輕ζ 提交于 2019-12-08 18:52:31

You can modify the behavior of your animation by applying it a Interpolator.
The AccelerateDecelerateInterpolator seems to be the best here.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_decelerate_interpolator">
<rotate
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="0"
    android:toDegrees="360"
    android:duration="200"
    android:repeatMode="restart"
    android:repeatCount="-1"
    android:pivotX="50%"
    android:pivotY="50%">
</rotate>
</set>

Or much simpler:

yourView.animate().rotation(value).setInterpolator(new AccelerateDecelerateInterpolator()).start();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!