yuyakaido / CardStackView

📱Tinder like swipeable card view for Android
Apache License 2.0
2.38k stars 452 forks source link

Resize effect when paginating for v.2.2.4 and above #232

Open filippodelfra opened 5 years ago

filippodelfra commented 5 years ago

Hi, I had my implementation based on cardstackview made with 2.2.3 and everything was working fine. After updating to 2.3.0 cards started to have a strange "resize" effect when paginating. I have implemented pagination using DiffUtil.Callback() and I'm checking if is the case to call pagination when onCardSwiped callback is invoked (like in the sample).
I've tracked down the issue to this commit https://github.com/yuyakaido/CardStackView/commit/89b19fa19894381fcfb2ee8493329e2e16a01545 Here is my card layout.

Thanks for any help

<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:custom="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?attr/selectableItemBackground"
        android:foreground="?attr/selectableItemBackground"
        app:cardUseCompatPadding="true"
        app:cardPreventCornerOverlap="false"
        app:cardCornerRadius="10dp"
        app:cardBackgroundColor="@android:color/white">

    <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        <View
                android:layout_width="match_parent"
                android:layout_height="13dp"
                android:id="@+id/upperbox"
                android:background="@color/tunifyGreen"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent"/>
        <TextView
                android:text="TextView"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:gravity="center_vertical|center_horizontal"
                android:id="@+id/tv_card_title"
                android:layout_marginTop="10dp"
                app:layout_constraintTop_toBottomOf="@+id/upperbox"
                app:layout_constraintStart_toStartOf="parent"
                android:layout_marginStart="25dp"
                app:layout_constraintEnd_toEndOf="parent"
                android:layout_marginEnd="25dp"
                android:textAppearance="@style/trainingHeaderFontNegative"/>

        <RelativeLayout
                android:id="@+id/image_xy_position_layout"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="10dp"
                app:layout_constraintTop_toBottomOf="@id/tv_card_title"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintBottom_toTopOf="@id/bottom_slide_hint" android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">

            <ImageView
                    android:src="@drawable/position_control"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:id="@+id/image_xy_position"/>

            <ImageView
                    android:layout_width="wrap_content"
                    android:layout_gravity="center_vertical|center_horizontal"
                    android:layout_height="wrap_content"
                    android:id="@+id/xy_positioner"
                    custom:srcCompat="@drawable/positive_track_handle_control"
                    android:layout_centerInParent="true"/>
        </RelativeLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/bottom_slide_hint"
                android:background="@color/card_bottom_backgroundcolor"
                android:layout_width="match_parent"
                android:layout_height="34dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintEnd_toEndOf="parent">

            <TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical|center_horizontal"
                    android:text="@string/training_session_card_slide_description"
                    app:layout_constraintEnd_toEndOf="parent"
                    android:layout_marginEnd="8dp"
                    app:layout_constraintStart_toStartOf="parent"
                    android:layout_marginStart="8dp"
                    android:layout_marginBottom="8dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    android:layout_marginTop="8dp"
                    app:layout_constraintTop_toTopOf="parent"
                    android:textAppearance="@style/trainingStepStyle"
                    android:textColor="#000000"/>
        </androidx.constraintlayout.widget.ConstraintLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
filippodelfra commented 5 years ago

Small update: It's not a resize animation. What happens is that the card being readded via pagination and is drawn in front then, the correct card reappears.