Android RecyclerView with CardView flipping

My RecyclerView provides a list of cards that can be fired (shifted), inspired by Android-SwipeToDismis. This part works.

Animation has now been added to flip cards as follows.

final AnimatorSet setRightOut = (AnimatorSet) AnimatorInflater.loadAnimator(mActivity, R.animator.flip_right_out);
final AnimatorSet setLeftIn = (AnimatorSet) AnimatorInflater.loadAnimator(mActivity, R.animator.flip_left_in);

setRightOut.setTarget(swipeView);
setLeftIn.setTarget(backView);
setRightOut.start();
setLeftIn.start();

The swipeView screenshot is a CardView that has shifted. And backView is a CardView that should replace swipeView with flipping animation.

Everything works fine when I use swipeView twice. Thus, he flips 360 degrees back to himself. But it seems I can’t show anything.

How to implement backView correctly? Below is my XML layout.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_front"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="blocksDescendants"
        card_view:cardElevation="@dimen/card_elevation">

        <LinearLayout ....</LinearLayout>

    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_back"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:descendantFocusability="blocksDescendants"
        card_view:cardElevation="@dimen/card_elevation">

        <LinearLayout ....</LinearLayout>

    </android.support.v7.widget.CardView>

</RelativeLayout>

With some further research, it looks like there is a view, but Alpha = 0. Here is some information from the log before starting the flip animation:

RecyclerFragment: ViewHolder {418f3088 position = 1 id = -1, oldPos = -1, pLpos: -1} RecyclerFragment: getBackCard: android.widget.RelativeLayout {418f1ab8 V.E........... I. 0,0-0,0} RecyclerFragment: swipeView: android.widget.RelativeLayout {418eda10 V.E... C......... 0, -13-480,638} RecyclerFragment: LP: android.widget.RelativeLayout$LayoutParams@418dc2b8 RecyclerFragment: backView: android.widget.RelativeLayout {418f1ab8 V.E........... I. 0,0-0,0}

swipView -, CardView, 180 . , . . !

+4
1

, swipeView RelativeLayout, backView - CardView. ; final frontView = swipeView.findViewById(R.id.front_card);

+1

All Articles