Card flip animation in android

POUYA KARIMI :

I have tired to make a flip card in android.Please make an image view,when I click on,it flip like  this

Cahid Enes Keleş :
imageView.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        final ObjectAnimator oa1 = ObjectAnimator.ofFloat(imageView, "scaleX", 1f, 0f);
        final ObjectAnimator oa2 = ObjectAnimator.ofFloat(imageView, "scaleX", 0f, 1f);
        oa1.setInterpolator(new DecelerateInterpolator());
        oa2.setInterpolator(new AccelerateDecelerateInterpolator());
        oa1.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                imageView.setImageResource(R.drawable.frontSide);
                oa2.start();
            }
        });
        oa1.start();
    }
});

This animation doesn't have any depth but maybe you will like it.

You can also set animation duration with

oa1.setDuration(1000);
oa2.setDuration(1000);

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=432057&siteId=1