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 for the card. Then, we'll need four animation files for the full card flip effect. Here are the steps to set up the project structure correctly and to create the resources needed:

  1. Once you have front and back images for the cards, copy them to the res/drawable folder as card_front.jpg and card_back.jpg (keep the original file extension of your images if different).
  2. Create an animator resource directory: res/animator. (In Android Studio, go to File | New | Android resource directory. When the New Android Resource dialog displays, choose animator in the Resource Type drop-down list.)
  3. Create card_flip_left_enter.xml ...

Get Android 9 Development Cookbook - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.