FloatingActionButton icon indicating copy to clipboard operation
FloatingActionButton copied to clipboard

Rotation animation shouldn't apply to the shadow on pre-Lollipop

Open geecko86 opened this issue 9 years ago • 4 comments

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.

geecko86 avatar Mar 13 '15 04:03 geecko86

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.

lordcodes avatar Mar 14 '15 08:03 lordcodes

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.

geecko86 avatar Mar 14 '15 13:03 geecko86

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.

makovkastar avatar Apr 05 '15 09:04 makovkastar

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.

geecko86 avatar Apr 05 '15 14:04 geecko86