Search code examples
androidview3dviewflipper

how to flip images like 3d animation in android?


i have images in 3d for example 1-10 images

in which i have (1-5) images from front to back in 3d shape left ward and similarly front to back right ward (6-10)

if we look at them a complete 3d shape is formed i want to use them with left and right swipe/flipping so that complete 3d view of that image is displayed.

i have seen this example but its far away from my view flipper and swipe. http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html

any one guide me how to achieve this?

any help would be appreciated.


Solution

  • You can add realistic 3D flip transition by building on Raghav Chopra's the 3D flip library https://code.google.com/p/android-3d-flip-view-transition.

    With that, all you have to do is instead of calling flipper.showNext(); call AnimationFactory.flipTransition(flipper, FlipDirection.LEFT_RIGHT); and you are done. The 3D animation is pretty cool.

    A lot of the other tutorials and sample codes (including the one you are using) don't produce believable 3D flips. A simple rotation on the y-axis isn't sufficient so take a look the above linke (or this video http://youtu.be/52mXHqX9f3Y).

    If you want to have it automatically transition, simply add a Handler like:

    Handler handler = new Handler();
    ...
    handler.postDelayed(new Runnable() {
        AnimationFactory.flipTransition(flipper, FlipDirection.LEFT_RIGHT);
    }, 500);
    

    The above will keep flipping through the images, indefinitely (cycling back to the first image at the end). To stop the auto transition, you add a boolean flag that you check before starting the flip, or save the Runnable you are using and call handler.removeCallbacks(runnable).