ViewFlipper 3D-Card-Flip

I started a new Android app and I have one problem.

I want to encode ViewFlipper in some ImageViews. (Not very difficult)

Elements must rotate (using this 3D-Flip anim .: http://www.inter-fuser.com/2009/08/android-animations-3d-flip.html ) when the user clicks on them. (I did it too).

My idea only works for the first item in the ViewFlipper. I started to fan this first look, but the new element does not flip.

Is it possible to β€œclone / copy” the first view with its onclick events, so that the second view is also flipped?

Thanks for the help.

+4
source share
2 answers

The best and easiest solution here: https://github.com/genzeb/flip

Use the flip transition in any of the ViewAnimator (e.g., ViewFipper) by doing:

AnimationFactory.flipTransition (viewFlipper, FlipDirection.LEFT_RIGHT);

+3
source

You can use this as a pattern, here is an animator object.

<?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 noticed that in some tutorial only valueTo is indicated. This will allow you to flip only once, since your view is already 360, it will no longer flip, so always use valueFrom. And here is 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(); } 
+1
source

Source: https://habr.com/ru/post/1486571/


All Articles