FloatingActionButton
FloatingActionButton copied to clipboard
Rotation animation shouldn't apply to the shadow on pre-Lollipop
You can see an example of that here at 1m40: https://youtu.be/xzNN693IY8I?t=1m40s When the FAB rotates, the shadow looks odd.
And the code is here: https://github.com/geecko86/QuickLyric/blob/master/QuickLyric/src/main/java/com/geecko/QuickLyric/view/RefreshIcon.java
Basically, any animation that's started this way:
New FloatingActionButton().startAnimation(rotateAnimation);
Applies to the shadow as well. It doesn't do that on Lollipop.
This will be because the shadow is performed by Android on Lollipop using elevation, but with an image file on the FAB for pre-Lollipop.
This could be fixed, by having a way to rotate the icon rather than the whole FAB.
From what I've seen, animations apply to views and the icon is not a view: it's the drawable used as background for the FAB. In my opinion a good fix would be to separate the shadow and the FAB as 2 separate views and to automatically transfer all animations to the FAB. I could take care of that but I'd rather have the author's opinion.
How about disabling the shadow for the FAB itself (fab:fab_shadow="false"
) and wrapping the FAB with a view group that provides a shadow for it. For example I have found this library that might be used: https://github.com/dmytrodanylyk/shadow-layout.
I'm not sure if it's a good idea to separate the FloatingActionButton class to two views.
I ended up doing something like that, yes. The problem is that if we need to implement a shadow manually, then we also need to hide and show it manually. It feels more like a hack.
This is cicumvents the problem but it doesn't solve it.