I started a new Android-App and I have one problem.
I want to code a ViewFlipper within some ImageViews. (Not really difficult)
The elements should turn (with this 3D-Flip anim.: http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html) when the user is clicking on them. (I have already implemented this, too).
My idea only works for the first element in the ViewFlipper. I started to inflate this first view, but the new element doesn`t flip.
Is it possible to "clone/copy" the first view with its onclick events, so that the second view is flipping, too?
Thanks for help.
The best and simplest solution is here: https://github.com/genzeb/flip
Use the flip transition in any of your ViewAnimator (such as ViewFipper) by doing:
AnimationFactory.flipTransition(viewFlipper, FlipDirection.LEFT_RIGHT);
You can use this as a sample, here's a object animator. :
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="rotationY"
android:valueFrom="0"
android:valueTo="360" >
</objectAnimator>
I have noticed that some tutorial states only valueTo. That will allow you to flip only once since your view is already on 360 it won't flip anymore so always use valueFrom as well. And here's the code that will flip any view:
public static void flip(Context context, View view) {
ObjectAnimator anim = (ObjectAnimator) AnimatorInflater.loadAnimator(
context, R.animator.flip);
anim.setTarget(view);
anim.setDuration(1000);
anim.end();
anim.start();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With