I have a FAB that I'd like to animate with a flip when one of two actions happen. The first is a change in screens content, and the second is pressing on the FAB to confirm the action.
I'm using the FAB from the support library v22.2.1
I'm using this object animator to do it
ObjectAnimator animation = ObjectAnimator.ofFloat(myFab, "rotationY", 0.0f, 360f);
animation.setDuration(400);
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.start();
The animation works as expected, the view flips and it looks perfect on per-lollipop devices.
On Lollipop device it's also flipping the shadow, which looks really bad and is distracting.
I have the FAB set to a 6 elevation
<android.support.design.widget.FloatingActionButton
android:id="@+id/my_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="@dimen/fab_compat_margin"
app:borderWidth="0dp"
app:elevation="6dp"/>
What I've done to get around this, is set the elevation to 0 before the animation starts, and in the onAnimationEnd I set it back to 6.
This works when the action that triggers the animation is not a pressed fab.
When I press the FAB, it still shows the shadow, and it's a bigger shadow. It looks like the pressed state shadow is seperate from the elevation shadow.
I tried setting up a touch listener and removing the shadow there, but the shadow already exists by then because of the touch.
Any ideas on how I can get around the touch shadow animating?
I figured it out.
If I set the StateListAnimatior to null the pressed shadow goes away and the animation works.
myFab.setStateListAnimator(null);
This shadow is seperate from the elevation shadow though, so I still need to set those to 0 before starting the animation.