I’m building an app with game cards and I’m looking into creating a custom View that has an ordinary card with a front and back that once clicked will be turned over from front to back.
I’v been using the Flip3DAnimation tutorial tutorial inorder to achieve the flipping of the card from front to back and it works perfectly. but after working on the app for a while I saw that there will be a serious problem on the next part of my app which is gonna be dragging and dropping of the card across the screen.
when I spoke to JakeWharton on the freenode chat this morning, I thought I should create an XML view and include it in the main.xml.
the problem is that when I try to move the included view around all I achieve is getting the image stuck to the top left. Question: How can I move the included xml around the parent View?
Code for Card:
<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="80dp"
android:layout_height="108dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/firstImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/c2" />
<ImageView
android:id="@+id/secondImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/back" />
</ViewFlipper>
Code for main.xml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Board"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:background="@drawable/pinecropped" >
<include
android:id="@+id/firstCard"
android:layout_marginRight="91dp"
android:layout_marginTop="102dp"
layout="@layout/card" />
</FrameLayout>
here is what I get as the graphical layout:

in the end I just created a different Class to handle the cards and had a layout in
main.xmlto represent it in the main activity code.