You may be creating an application that requires the ability to show some swipe cards. Users would probably swipe just to view some info like news articles or swipe to select. This type of features is common in dating apps where you swipe to select a person.
In this thread lets share some examples and best libraries so that you can easily add this feature in your app.
Feel free to add some yourself.
Oclemy
Swipe Cards with SwipeView
SwipeView is a a Tinder style StackSwipeview gesture library. It supports android API 15 and above.
Here is how to use it.
Step 1 – Installation
To Install the library first add jitpack in your project level’s build.gradle:
Then the dependency statement in your app level’s build.gradle:
Step 2 – Layout
Add the SwipeView in your layout:
Step 3 – Code
In your activity or fragment start by initializing your recyclerview as usual:
then set
CardLayoutManager
for RecyclerView andCardItemTouchHelperCallback
for ItemTouchHelper . In addition , don’t forget setOnSwipeListener
forCardItemTouchHelperCallback
:Full Example
Here is a full example of how to use swipe view.
(a). MainActivity
Here is the code for our only class, the main activity.
Run
If you run the project you get the following:
Oclemy
ShyShark
ShyShark is Swipeable card stack view like Tinder.
This library is written in Kotlin by extending RecyclerView to create a ShySharkView. The library is written with only 4 kotlin files so it’s easy to customize if you want to create something unique. Furthermore, it doesn’t use any external library. The only package it utilizes is RecyclerView and of course the AppCompat. This makes it reliable to use and lightweight.
Step 1 – How to Install
Install it using the following command:
Step 2
Add the following to your layout.
Step 3
Then in kotlin code:
FULL EXAMPLE
Let’s look at a full example, to create swipeable cards.
(a). SimpleAdapter.kt
First create an adapter class.
(a). MainActivity.kt
Then a main activity class.
Demo
Here is what you get:
Download
This example is written by @sabujak-sabujak.
Direct Download the code here.