val cardStackView = findViewById<CardStackView>(R.id.card_stack_view)
cardStackView.layoutManager =CardStackLayoutManager()
cardStackView.adapter =CardStackAdapter()
Features
Manual Swipe
Automatic Swipe
CardStackView.swipe()
You can set custom swipe animation.
val setting =SwipeAnimationSetting.Builder()
.setDirection(Direction.Right)
.setDuration(Duration.Normal.duration)
.setInterpolator(AccelerateInterpolator())
.build()
CardStackLayoutManager.setSwipeAnimationSetting(setting)
CardStackView.swipe()
Cancel
Manual swipe is canceled when the card is dragged less than threshold.
Rewind
CardStackView.rewind()
You can set custom rewind animation.
val setting =RewindAnimationSetting.Builder()
.setDirection(Direction.Bottom)
.setDuration(Duration.Normal.duration)
.setInterpolator(DecelerateInterpolator())
.build()
CardStackLayoutManager.setRewindAnimationSetting(setting)
CardStackView.rewind()
Overlay View
Value
Sample
Left
Right
Put overlay view in your item layout of RecyclerView.
<FrameLayoutandroid:id="@+id/left_overlay"android:layout_width="match_parent"android:layout_height="match_parent">
<!-- Set your left overlay -->
</FrameLayout>
Value
Layout ID
Left
left_overlay
Right
right_overlay
Top
top_overlay
Bottom
bottom_overlay
Overlay Interpolator
You can set own interpolator to define the rate of change of alpha.
You should NOT call RecyclerView.Adapter.notifyDataSetChanged for paging because this method will reset top position and maybe occur a perfomance issue.
Reloading
You can implement reloading by calling RecyclerView.Adapter.notifyDataSetChanged.
Copyright 2018 yuyakaido
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
E/MessageQueue-JNI: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getTop()' on a null object reference
at com.yuyakaido.android.cardstackview.CardStackLayoutManager.updateProportion(CardStackLayoutManager.java:165)
at com.yuyakaido.android.cardstackview.CardStackView.onTouch(CardStackView.java:48)
at android.view.View.dispatchTouchEvent(View.java:10713)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2859)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2535)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2865)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2492)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:559)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1870)
at android.app.Activity.dispatchTouchEvent(Activity.java:3236)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:69)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:521)
at android.view.View.dispatchPointerEvent(View.java:10946)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:5110)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4962)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4493)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4546)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4512)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4645)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4520)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4702)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4493)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4546)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4512)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4520)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4493)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7000)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6929)
at android.view.ViewRootImpl.enqueueInputEvent(V
Got this nullpointer error when fast swiping.
I already took a look at isseu #51 but nothing in here helped.
Hey i am facing this error when i remove jcenter from my code
Could not resolve com.yuyakaido.android:card-stack-view:2.3.4.
Required by:
project :app
> Could not resolve com.yuyakaido.android:card-stack-view:2.3.4.
> Could not get resource 'http://dl.bintray.com/amulyakhare/maven/com/yuyakaido/android/card-stack-view/2.3.4/card-stack-view-2.3.4.pom'.
> Could not HEAD 'http://dl.bintray.com/amulyakhare/maven/com/yuyakaido/android/card-stack-view/2.3.4/card-stack-view-2.3.4.pom'. Received status code 502 from server: Bad Gateway
First of all, amazing library! 🚀 The API is super straightforward and the whole library is a pleasure to work with. I'm actually using this library to implement some modals and it has really simplified a lot of things for me. Thanks! 🙇
Question
Is there any hook function or any callback I could use to obscure the stack cards that we have behind the main card 👇
What I want is to display some sort of black overlay on top of those stack cards, and have it fade away as we dismiss the current card.
I was thinking about using the onCardDragging(direction: Direction?, ratio: Float) callback but I don't have any reference to the view.
Again, thanks for this library it truly saved me from some headaches! 🙇
Like many others, I needed to have a RecyclerView (ViewPager2) within my cards. Here is how I worked around it.
Disable/Enable Horizontal Swiping
I needed to be able to conditionally disable and enable horizontal swiping of the cards based on events within an item. To do so, I had a listener that could be passed into the adapter upon creation.
interface MatchItemListener {
fun disableCardSwipe()
fun enableCardSwipe()
}
And here is the integration of this listener upon adapter creation. Notice we are disabling/enabling the horizontal scrolling in the CardStackLayoutManager assigned to our parent's layoutManager.
Now we need to intercept the touches in the child items to disable/enable horizontal swiping in the parent's CardStackLayoutManager.
First, create a custom ViewGroup. In this instance, mine is a ConstraintLayout. In this we are doing some collision detection to see if the touch occurred in the view where we want to scroll horizontally. If its within this view, we call the listener to disable horizontal card swiping, otherwise we enable it again.
class MatchItemContainer @kotlin.jvm.JvmOverloads constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
var listener: MatchItemListener? = null
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
val x = round(ev.x).toInt()
val y = round(ev.y).toInt()
if (isTouchInsideView(findViewById<ViewPager2>(R.id.carousel),x, y)) {
listener?.disableCardSwipe()
} else listener?.enableCardSwipe()
return super.dispatchTouchEvent(ev)
}
private fun isTouchInsideView(view: View, x: Int, y: Int): Boolean =
(x > view.left && x < view.right) &&
(y > view.top && y < view.bottom)
}
Setting Listener on Each Child
We can share the same listener on each of the children. When the adapter creates the ViewHolder or whatever mechanism you're using to inflate your layout into a view, we assign the listener to our custom ViewGroup.
Here is how I'm doing it (I'm using the FastAdapter library so its inflating a ViewBinding but the principle is the same).
Inspiration
This was inspired by SwipeStack and other libraries like it.
Screenshots
Usage
<chi.widget.StackView
android:id="@+id/stackView"
android:layout_width="match_parent"
android:la
CarouselView
Useful library for showing list in sliding mode or carousel mode
Options
showing horizontal and vertical
auto scrolling (with pause/resume)
change listener scrolling
slider mode/ carousel mode
change s
StackCardLayoutManager
This project is the movement of a new card type UI for Android
Screenshots
Requirements
Min Sdk Version : 21
How to use
Add this to your build.gradle.
repo
ElasticView
Elastic view is a regular CardView, which can flex from user touches
💪
Kotlin
❤️
Let's see it in action
💻
📲
Download sample apk
⬇️
The current minSDK version
SwipeableCards
Library for creating Tinder-like swipe cards effect using RecyclerView
Features
Library provides three Helper classes for creating tinder-like swipe card effect with recycler view
SwipeableTou
ExpandableCardView
An Android library that lets you create in a simple, fast and hassle-free way a CardView in which you can insert your custom layout and just expand and collapse without even writing a single Java/Kotlin l
TicketView
An Android Library used to implement TicketView in android with normal, rounded and scallop corners.
Specs
Badges/Featured In
Sample Project
For information : checkout Sampl
Deck
What is it?
Deck is a library that permits you to apply a beautiful animation in your view pager, and this animations looks like a deck... yeah, I'm not good with names.
How does it works?
First of
CardsLayout
CardsLayout is a lightweight Collection Layout.
Installation
CocoaPods
You can use CocoaPods to install TextFieldCounter by adding it to your Podfile:
platform :ios, '9.0'
use_framewor
shadow
This library draw android view shadow by ShadowLayer. You may don't like the CardView's black shadow which we can't change it's color. Same to CardView wrap content and set shadow radius. You can change shadow color, foreg