How to rotate floating action button without rotating shadow?
Did you try with the animate method provided by the Compat library? I too had the same problem when using Animation utils
final OvershootInterpolator interpolator = new OvershootInterpolator();
ViewCompat.animate(fab).
rotation(135f).
withLayer().
setDuration(300).
setInterpolator(interpolator).
start();
Shortest way: For clockwise rotation:
fab.animate().rotationBy(135f) // 135f = 135 degree.
For anticlockwise rotation (reset to initial position):
fab.animate().rotationBy(-135f) // 135f = 135 degree.
public void rotateFabForward() {
ViewCompat.animate(fab)
.rotation(135.0F)
.withLayer()
.setDuration(300L)
.setInterpolator(new OvershootInterpolator(10.0F))
.start();
}
public void rotateFabBackward() {
ViewCompat.animate(fab)
.rotation(0.0F)
.withLayer()
.setDuration(300L)
.setInterpolator(new OvershootInterpolator(10.0F))
.start();
}