我想为浮动按钮实现动画
i want implement animation for Floating Button
我想为我的浮动按钮提供一个完整的旋转动画,我有代码,但它只是像旋转一半这样的动画。我想从一个位置旋转浮动按钮,它应该在开始时的相同位置结束(完整旋转),该怎么做?
这是我的代码,我希望有人修改值或代码
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);
我想为我的浮动按钮提供一个完整的旋转动画,我有代码,但它只是像旋转一半这样的动画。我想从一个位置旋转浮动按钮,它应该在开始时的相同位置结束(完整旋转),该怎么做?
这是我的代码,我希望有人修改值或代码
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);