I Want to create this type of animation on FloatingActionButton
What I have tried
public void animFab() {
ObjectAnimator scaleX = ObjectAnimator.ofFloat(fab, View.SCALE_X, from, to);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(fab, View.SCALE_Y, from, to);
ObjectAnimator translationZ = ObjectAnimator.ofFloat(fab, View.TRANSLATION_Z, from, to);
AnimatorSet set1 = new AnimatorSet();
set1.playTogether(scaleX, scaleY, translationZ);
set1.setDuration(500);
set1.setInterpolator(new AccelerateInterpolator());
set1.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
}
});
ObjectAnimator scaleXBack = ObjectAnimator.ofFloat(fab, View.SCALE_X, to, from);
ObjectAnimator scaleYBack = ObjectAnimator.ofFloat(fab, View.SCALE_Y, to, from);
ObjectAnimator translationZBack = ObjectAnimator.ofFloat(fab, View.TRANSLATION_Z, to, from);
Path path = new Path();
path.moveTo(0.0f, 0.0f);
path.lineTo(0.5f, 1.3f);
path.lineTo(0.75f, 0.8f);
path.lineTo(1.0f, 1.0f);
PathInterpolator pathInterpolator = new PathInterpolator(path);
AnimatorSet set2 = new AnimatorSet();
set2.playTogether(scaleXBack, scaleYBack, translationZBack);
set2.setDuration(500);
set2.setInterpolator(pathInterpolator);
final AnimatorSet set = new AnimatorSet();
set.playSequentially(set1, set2);
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
set.start();
}
});
set.start();
}
The Problem
The Above code is working fine Lolipop and above device but not working in KitKat device
Below are some links I have tried
- Animating Fab on click (zoom in/out)
- ObjectAnimator starting with a frame jump on Android 4.4 (nexus 5) but not in 4.1 device
- Implementing ImageView transition between activities for pre-Lollipop devices.
- How to achieve Transition animation in Pre lollipop devices
- Material Transitions in pre lollipop apps
- Android ImageView Zoom-in and Zoom-out Continuously
Can anyone help to solve the problem in KitKat device
If need more information please do let me know. Thanks in advance. Your efforts will be appreciated.
See Question&Answers more detail:os