我想给我的浮动按钮一个完整的旋转动画,我有代码,但它只是像旋转一半一样动画。我想从一个位置旋转浮动按钮,它应该在它开始的相同位置结束(完整旋转),怎么做?
这是我的代码,我希望有人修改值或代码
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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句