{"id":13642478,"url":"https://github.com/wenchaojiang/AndroidSwipeableCardStack","last_synced_at":"2025-04-20T16:32:30.732Z","repository":{"id":23338685,"uuid":"26699164","full_name":"wenchaojiang/AndroidSwipeableCardStack","owner":"wenchaojiang","description":"A tinder like swipeable card stack component","archived":false,"fork":false,"pushed_at":"2022-07-23T17:30:19.000Z","size":9705,"stargazers_count":832,"open_issues_count":37,"forks_count":184,"subscribers_count":32,"default_branch":"master","last_synced_at":"2024-08-02T01:16:00.591Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wenchaojiang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-16T00:44:56.000Z","updated_at":"2024-07-25T15:09:24.000Z","dependencies_parsed_at":"2022-08-21T22:50:31.569Z","dependency_job_id":null,"html_url":"https://github.com/wenchaojiang/AndroidSwipeableCardStack","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenchaojiang%2FAndroidSwipeableCardStack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenchaojiang%2FAndroidSwipeableCardStack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenchaojiang%2FAndroidSwipeableCardStack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenchaojiang%2FAndroidSwipeableCardStack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenchaojiang","download_url":"https://codeload.github.com/wenchaojiang/AndroidSwipeableCardStack/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223833117,"owners_count":17210784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:01:31.932Z","updated_at":"2024-11-09T13:32:02.692Z","avatar_url":"https://github.com/wenchaojiang.png","language":"Java","readme":"AndroidSwipeableCardStack\n=========================\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-AndroidSwipeableCardStack-green.svg?style=true)](https://android-arsenal.com/details/1/2724)\n\n\nChange log:\n\n- provide option to infinitly swipe in a loop\n- card rotation setting\n- card gravity setting\n- undo animation\n\nThanks for contributions from:\nhttps://github.com/raee\nhttps://github.com/rebus007\n \n\n![image](https://github.com/raee/AndroidSwipeableCardStack/raw/RAE-DEV/pics/demo.gif)\n\n\n\nA tinder like swipeable card stack component. Provide \"swipe to like\" effects. Easy to customize card views.\n\n\nSee youtube demo : https://www.youtube.com/watch?v=YsMnLJeouf8\u0026feature=youtu.be\nA Demo App is also included in the source.\n\n\nInstallation\n---\nUse jitpack\n```groovy\nrepositories {\n   maven { url \"https://jitpack.io\" }\n}\n\ndependencies {\n   compile 'com.github.wenchaojiang:AndroidSwipeableCardStack:0.*.*'\n}\n```\nOR manually\n\n1. Download released .aar file\n[Download current release] (https://github.com/wenchaojiang/AndroidSwipeableCardStack/releases/)\n\n2. put it into your project lib dir, \"libs\" for example.\n\n3. put following lines to your gradle.build file\n```groovy\nrepositories {\n    flatDir {\n        dirs 'libs'\n    }\n}\n\ndependencies {\n    compile(name:'android-card-stack-0.*.*', ext:'aar')\n}\n```\n\nConfiguration\n-----\n\n\nPut CardStack in your layout file\n\n```xml\n\u003ccom.wenchao.cardstack.CardStack\n        android:id=\"@+id/container\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:clipChildren=\"false\"\n        android:clipToPadding=\"false\"\n        android:gravity=\"center\"\n        android:padding=\"10dp\"\n        app:card_enable_loop=\"true\"\n        app:card_enable_rotation=\"true\"\n        app:card_gravity=\"top\"\n        app:card_margin=\"10dp\"\n        app:card_stack_size=\"4\"/\u003e\n```\n\nCreate your card view layout file.\n\nExample: card_layout.xml, contain only a TextView\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:orientation=\"vertical\" android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\u003e\n    \u003cTextView\n        android:id=\"@+id/content\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n    /\u003e\n\n\u003c/LinearLayout\u003e\n```\n\nImplement your own adapter for the card stack. The CardStack will accept ArrayAdapter.\nThe Following example extends a simple ArrayAdapter\u003cString\u003e, overriding ```getView()``` to supply your customized card layout\n\n```java\npublic class CardsDataAdapter extends ArrayAdapter\u003cString\u003e {\n\n    @Override\n    public View getView(int position, final View contentView, ViewGroup parent){\n        //supply the layout for your card\n        TextView v = (TextView)(contentView.findViewById(R.id.content));\n        v.setText(getItem(position));\n        return contentView;\n    }\n\n}\n```\nGet the CardStack instance in your activity\n\n```java\n  protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_my);\n\n        mCardStack = (CardStack)findViewById(R.id.container);\n\n        mCardStack.setContentResource(R.layout.card_content);\n        mCardStack.setStackMargin(20);\n        \n  }\n  ```\n  \nFinally, set the adapter \n\n\n```java\n    mCardAdapter = new CardsDataAdapter(getApplicationContext(),0);\n    mCardAdapter.add(\"test1\");\n    mCardAdapter.add(\"test2\");\n    mCardAdapter.add(\"test3\");\n    mCardAdapter.add(\"test4\");\n    mCardAdapter.add(\"test5\");\n    \n    mCardStack.setAdapter(mCardAdapter);\n```\n\n\nListening to card stack event \n----\nimplement CardStack.CardEventListener, and set it as listener ```mCardStack.setListener(yourListener);   ```\n\n```java\nClass YourListener extends CardStack.CardEventListener{\n    //implement card event interface\n    @Override\n    public boolean swipeEnd(int direction, float distance) {\n        //if \"return true\" the dismiss animation will be triggered \n        //if false, the card will move back to stack\n        //distance is finger swipe distance in dp\n        \n        //the direction indicate swipe direction\n        //there are four directions\n        //  0  |  1\n        // ----------\n        //  2  |  3\n        \n        return (distance\u003e300)? true : false;\n    }\n\n    @Override\n    public boolean swipeStart(int direction, float distance) {\n    \n        return true;\n    }\n\n    @Override\n    public boolean swipeContinue(int direction, float distanceX, float distanceY) {\n        \n        return true;\n    }\n\n    @Override\n    public void discarded(int id, int direction) {\n       //this callback invoked when dismiss animation is finished. \n    }\n    \n    @Override\n    public void topCardTapped() {\n         //this callback invoked when a top card is tapped by user. \n    }\n}\n```\n\n","funding_links":[],"categories":["Libs","Card"],"sub_categories":["\u003cA NAME=\"Widget\"\u003e\u003c/A\u003eWidget"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenchaojiang%2FAndroidSwipeableCardStack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenchaojiang%2FAndroidSwipeableCardStack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenchaojiang%2FAndroidSwipeableCardStack/lists"}