October 2018
Intermediate to advanced
464 pages
15h 17m
English
Most of the effort to create the card flip is in setting up the resources. Since we want a front and back view of the card, we create two fragments with the appropriate images. We call the flipCard() method when the card is pressed. The actual animation is handled by setCustomAnimations(). This is where we pass in the four animation resources we defined in the XML. As you can see, Android makes it very easy.
It's important to note that we did not use the Support Library Fragment Manager, as the support library does not support objectAnimator. If you want support pre-Android 3.0, you'll need to include the old anim resources and check the OS version at runtime, or create the animation resources in code. (See the next recipe.) ...