Creating a Card Flip Animation with Fragments
The card flip is a common animation that we will demonstrate using fragment transitions. We'll use two different images, one for the front and one for the back, to create the card flip effect. We'll need four animation resources, two for the front and two for the back transitions, which we will define in XML using objectAnimator
.
Here's a screenshot of the application we'll build showing the Card Flip Animation in action:
Getting ready
Create a new project in Android Studio and call it CardFlip
. Use the default Phone & Tablet
options and select Empty Activity
when prompted for the Activity Type
.
For the front and back images of the playing card, we found the following images on www.pixabay.com:
How to do it...
We'll need two fragments: one for the front of the card and the other for the back. Each fragment will define the image...