Closed andrea-liu87 closed 2 years ago
Hi, I am not sure what is wrong in my layout. The horizontal swipe is perfectly fine in my layout. But the vertical swipe is not working.
Layout : `<androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipChildren="false" app:contentInsetLeft="0dp" app:contentInsetStart="0dp">
<androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="300dp" android:clipChildren="false"> <com.yuyakaido.android.cardstackview.CardStackView android:id="@+id/rvCardsList" android:layout_width="match_parent" android:layout_height="match_parent" android:alpha="1" android:clipToPadding="false" android:elevation="5dp" android:outlineSpotShadowColor="@color/blue" android:padding="7dp" android:translationZ="1dp" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" tools:listitem="@layout/list_item_card_pager" /> </androidx.constraintlayout.widget.ConstraintLayout> </androidx.appcompat.widget.Toolbar>`
recyclerview item ` <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent">
<com.google.android.material.card.MaterialCardView android:id="@+id/cardView" android:layout_width="343dp" android:layout_height="233dp" app:cardBackgroundColor="@color/blue" app:cardCornerRadius="32dp" app:cardElevation="14dp" app:strokeColor="@color/off_white" app:strokeWidth="4dp" android:outlineSpotShadowColor="@color/blue" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/ivBGCard" android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="" /> <RelativeLayout android:id="@+id/relativeLayout" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toStartOf="@+id/iv_edit" android:orientation="vertical"> <TextView android:id="@+id/tvCardName" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="20dp" android:lineSpacingExtra="7sp" android:singleLine="true" android:text="@{data.cardName}" android:textColor="@color/off_white" android:textSize="17sp" tools:text="Personal card" /> <TextView android:id="@+id/tvLast4Digits" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="24dp" android:lineSpacingExtra="7sp" android:text='@{String.format("%s %s", "Visa ••", data.last4Digits)}' android:textColor="@color/off_white_twentyfive" android:textSize="14sp" tools:text="Visa ••1234" /> </LinearLayout> <ImageView android:id="@+id/iv_edit" android:layout_width="44dp" android:layout_height="44dp" android:layout_alignParentEnd="true" android:layout_marginTop="20dp" android:layout_marginEnd="2dp" android:background="@drawable/bg_edit_card" android:contentDescription="" android:cropToPadding="true" android:padding="10dp" android:src="@drawable/ic_edit_24_px" app:tint="@color/white" /> </RelativeLayout> <TextView android:id="@+id/tvTotalILS" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="24dp" android:layout_marginTop="27dp" android:lineSpacingExtra="12sp" android:text='@{String.format("%s %s", (data.totalSum == null ? "" : data.totalSum), "ILS")}' android:textColor="@color/off_white" android:textSize="24sp" android:textStyle="bold" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/relativeLayout" tools:text="18,678.00 ILS" /> <TextView android:id="@+id/tvTotalUSD" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="24dp" android:lineSpacingExtra="9sp" android:text='@{String.format("%s %s", (data.totalSum == null ? "" : data.totalSum), "USD")}' android:textColor="@color/off_white_twentyfive" android:textSize="18sp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/tvTotalILS" tools:text="678.00 USD" /> <ImageView android:id="@+id/imageView2" android:layout_width="130dp" android:layout_height="55dp" android:layout_gravity="center" android:background="@drawable/card_footer_background" android:contentDescription="" android:scaleType="centerCrop" app:image_value="@{data.company}" app:layout_constraintBottom_toBottomOf="@+id/tvTotalUSD" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="@+id/tvTotalILS" tools:src="@drawable/image_amex" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:lineSpacingExtra="7sp" android:text="Credit limit" android:textColor="@color/off_white_twentyfive" android:textSize="14sp" app:layout_constraintStart_toStartOf="@+id/tvTotalILS" app:layout_constraintTop_toTopOf="@+id/tv_creditlimit" /> <TextView android:id="@+id/card_label" android:layout_width="wrap_content" android:layout_height="wrap_content" android:lineSpacingExtra="7sp" android:visibility="visible" android:textColor="@color/off_white_twentyfive" android:textSize="14sp" android:layout_marginBottom="4dp" android:text="@{data.cardName}" app:layout_constraintStart_toStartOf="@+id/tvTotalILS" app:layout_constraintBottom_toBottomOf="parent" tools:text="Card One"/> <TextView android:id="@+id/tv_creditlimit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="21dp" android:layout_marginEnd="24dp" android:lineSpacingExtra="12sp" android:text='@{String.format("%s %s", (data.creditLimit == null ? "" : data.creditLimit), "ILS")}' android:textColor="@color/off_white" android:textSize="17sp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/imageView2" tools:text="15,000.00 ILS" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@{data.expirationDate}" android:textSize="14sp" android:textColor="@color/off_white_twentyfive" android:lineSpacingExtra="7sp" app:layout_constraintEnd_toEndOf="@+id/tv_creditlimit" app:layout_constraintTop_toBottomOf="@+id/tv_creditlimit" tools:text="30 Apr 2021" /> </androidx.constraintlayout.widget.ConstraintLayout> </com.google.android.material.card.MaterialCardView> </androidx.constraintlayout.widget.ConstraintLayout>`
setup : manager.setStackFrom(StackFrom.Bottom); manager.setVisibleCount(cardsNumber); manager.setTranslationInterval(24.0f); manager.setScaleInterval(0.85f); manager.setDirections(Direction.VERTICAL); manager.setMaxDegree(0f); manager.setOverlayInterpolator(new LinearInterpolator()); manager.setSwipeableMethod(SwipeableMethod.AutomaticAndManual); manager.setSwipeThreshold(0.3f); binding.rvCardsList.setLayoutManager(manager); binding.rvCardsList.setAdapter(viewModel.cardPagerAdapter); ((SimpleItemAnimator) binding.rvCardsList.getItemAnimator()).setSupportsChangeAnimations(false);
manager.setStackFrom(StackFrom.Bottom); manager.setVisibleCount(cardsNumber); manager.setTranslationInterval(24.0f); manager.setScaleInterval(0.85f); manager.setDirections(Direction.VERTICAL); manager.setMaxDegree(0f); manager.setOverlayInterpolator(new LinearInterpolator()); manager.setSwipeableMethod(SwipeableMethod.AutomaticAndManual); manager.setSwipeThreshold(0.3f); binding.rvCardsList.setLayoutManager(manager); binding.rvCardsList.setAdapter(viewModel.cardPagerAdapter); ((SimpleItemAnimator) binding.rvCardsList.getItemAnimator()).setSupportsChangeAnimations(false);
Hello. I have found my issue. It is because my root layout using Coordinator Layout. Once I changed the root layout to ConstraintLayout. The problem is solved.
Hi, I am not sure what is wrong in my layout. The horizontal swipe is perfectly fine in my layout. But the vertical swipe is not working.
Layout : `<androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipChildren="false" app:contentInsetLeft="0dp" app:contentInsetStart="0dp">
recyclerview item ` <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/transparent">
setup :
manager.setStackFrom(StackFrom.Bottom); manager.setVisibleCount(cardsNumber); manager.setTranslationInterval(24.0f); manager.setScaleInterval(0.85f); manager.setDirections(Direction.VERTICAL); manager.setMaxDegree(0f); manager.setOverlayInterpolator(new LinearInterpolator()); manager.setSwipeableMethod(SwipeableMethod.AutomaticAndManual); manager.setSwipeThreshold(0.3f); binding.rvCardsList.setLayoutManager(manager); binding.rvCardsList.setAdapter(viewModel.cardPagerAdapter); ((SimpleItemAnimator) binding.rvCardsList.getItemAnimator()).setSupportsChangeAnimations(false);