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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.