Back to rankings

yuqirong/CardSwipeLayout

Java

Use RecyclerView to achieve card swipe layout , like Tantan . (模仿探探卡片滑动效果的布局)

androidrecyclerviewlayoutmanageritemtouchhelper
Star Growth
Stars
1.3k
Forks
185
Weekly Growth
Issues
23
5001k
Jan 2023Mar 2024May 2025Jul 2026
ArtifactsMavengit clone https://github.com/yuqirong/CardSwipeLayout.git
README

CardSwipeLayout

License

Introduction

CardSwipeLayout - Use RecyclerView to achieve card swipe layout , like Tantan .

Screenshot

screenshot.gif

Blog

《玩转仿探探卡片式滑动效果》

Usage

step 1

For build.gradle :

compile 'me.yuqirong:cardswipelayout:1.0.0'

Or Maven :

<dependency>
  <groupId>me.yuqirong</groupId>
  <artifactId>cardswipelayout</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

step 2

init RecyclerView firstly :

RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setAdapter(...);

step 3

then set CardLayoutManager for RecyclerView and CardItemTouchHelperCallback for ItemTouchHelper . In addition , don't forget set OnSwipeListener for CardItemTouchHelperCallback :

// dataList means dataSource for adapter
CardItemTouchHelperCallback cardCallback = new CardItemTouchHelperCallback(recyclerView.getAdapter(), dataList);
ItemTouchHelper touchHelper = new ItemTouchHelper(cardCallback); CardLayoutManager cardLayoutManager = new CardLayoutManager(recyclerView, touchHelper);
recyclerView.setLayoutManager(cardLayoutManager);
touchHelper.attachToRecyclerView(recyclerView);
cardCallback.setOnSwipedListener(new OnSwipeListener<T>() {

    @Override
    public void onSwiping(RecyclerView.ViewHolder viewHolder, float ratio, int direction) {
        /**
         * will callback when the card are swiping by user
         * viewHolder : thee viewHolder of swiping card
         * ratio : the ratio of swiping , you can add some animation by the ratio
         * direction : CardConfig.SWIPING_LEFT means swiping from left;CardConfig.SWIPING_RIGHT means swiping from right
         *             CardConfig.SWIPING_NONE means not left nor right
         */
    }

    @Override
    public void onSwiped(RecyclerView.ViewHolder viewHolder, T t, int direction) {
	    /**
	     *  will callback when the card swiped from screen by user
	     *  you can also clean animation from the itemview of viewHolder in this method
	     *  viewHolder : the viewHolder of swiped cards
	     *  t : the data of swiped cards from dataList
	     *  direction : CardConfig.SWIPED_LEFT means swiped from left;CardConfig.SWIPED_RIGHT means swiped from right
	     */
    }

    @Override
    public void onSwipedClear() {
        /**
         *  will callback when all cards swiped clear
         *  you can load more data 
         */
    }

});

Finally , enjoy it !!!

If you have any questions , you can leave a message in Issues.

Contact Me

License

MIT License

Copyright (c) 2017 yuqirong

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Related repositories
flutter/flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond

DartBSD 3-Clause "New" or "Revised" Licensemobileandroid
flutter.dev
177.9k30.7k
Genymobile/scrcpy

Display and control your Android device

CApache License 2.0androidc
146.1k13.5k
react/react-native

A framework for building native applications using React

C++MIT Licenseandroidapp-framework
reactnative.dev
126.2k25.2k
facebook/react-native

A framework for building native applications using React

C++MIT Licenseandroidapp-framework
reactnative.dev
120.9k24.5k
rustdesk/rustdesk

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

Rustcrates.ioGNU Affero General Public License v3.0remote-controlremote-desktop
rustdesk.com
118.6k18.1k
justjavac/free-programming-books-zh_CN

:books: 免费的计算机编程类中文书籍,欢迎投稿

GNU General Public License v3.0pythonjavascript
weibo.com/justjavac
117.7k28.2k
Hack-with-Github/Awesome-Hacking

A collection of various awesome lists for hackers, pentesters and security researchers

Creative Commons Zero v1.0 Universalhackingsecurity
116.6k10.5k
tldr-pages/tldr

Collaborative cheatsheets for console commands 📚.

MarkdownOthershellman-page
tldr.sh
63.2k5.3k
Solido/awesome-flutter

An awesome list that curates the best Flutter libraries, tools, tutorials, articles and more.

Dartflutterawesome-list
60.7k6.9k
2dust/v2rayNG

A V2Ray client for Android, support Xray core and v2fly core

KotlinGNU General Public License v3.0androidproxy
v2rayng.2dust.link
59.9k7.8k
termux/termux-app

Termux - a terminal emulator application for Android OS extendible by variety of packages.

JavaMavenOtherandroidterminal
f-droid.org/en/packages/com.termux
57.9k7k
wasabeef/awesome-android-ui

A curated list of awesome Android UI/UX libraries

MIT Licenseandroidawesome
56.9k10.3k