Android 我想为浮动按钮实现动画

Android 我想为浮动按钮实现动画,android,android-animation,floating-action-button,Android,Android Animation,Floating Action Button,我想给我的浮动按钮一个完整的旋转动画,我有代码,但它只是像旋转一半动画。我想从一个位置旋转浮动按钮,它应该以它开始的相同位置结束(完全旋转),怎么做 这是我的代码,我想有人修改值或代码 final OvershootInterpolator interpolator = new OvershootInterpolator(); ViewCompat.animate(fab). rotation(170f).

我想给我的浮动按钮一个完整的旋转动画,我有代码,但它只是像旋转一半动画。我想从一个位置旋转浮动按钮,它应该以它开始的相同位置结束(完全旋转),怎么做

这是我的代码,我想有人修改值或代码

  final OvershootInterpolator interpolator = new OvershootInterpolator();
            ViewCompat.animate(fab).
                    rotation(170f).
                    withLayer().
                    setDuration(1000).
                    setInterpolator(interpolator).
                    start();

在res/anim中生成rotate.xml:

 <?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <rotate

        android:fromDegrees="0"
        android:toDegrees="360"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="0"
        android:duration="1000" />

</set>
如果在活动中,请使用“此”而不是“上下文”
 FloatingActionButton mFloatingButton = view.findViewById(R.id.myFloatingButton);

        Animation mAnimation = AnimationUtils.loadAnimation(this, R.anim.rotate);

        mFloatingButton.startAnimation(mAnimation);