Android 2D Card Flip Animation Tutorial

2D Card flip animation will be implement by animate flipping effect between two imageview in the Framelayout. It is very useful in the particular situation for example you want to display a picture with both sides. You can use two imageview in one frame layout and create the card flip effect, so it will seem like a virtual card in the device. In this tutorial, I will give you the source code on how to create this effect in the imageview. Its just very easy you just need to follow my steps.

Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “2DCardExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Activity” and Click Next button
5. Lastly, press finish button.

Add 2 image in the res> drawable folder

You can download any image from the internet and copy paste those image in the res > drawable folder.

Edit activity_main.xml layout

Change the relative layout to frame layout and I will add two imageview in this frame layout. You can copy the source code below.

Edit MainActivity.java class

Open MainActivity.java and copy paste the following source code. This java class is to create the flipping animation between two image.

Run your Project

Now, you can run it on your android device to test out the flipping effect.

(Android 2D Card Flip Animation)

Source Code

(Visited 1,715 times, 1 visits today)
Advertisements

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *