{"id":13642943,"url":"https://github.com/BakerJQ/Android-InfiniteCards","last_synced_at":"2025-04-20T21:32:12.481Z","repository":{"id":44377850,"uuid":"85288056","full_name":"BakerJQ/Android-InfiniteCards","owner":"BakerJQ","description":"An infinite card switching UI for Android, support custom animation    自定义实现神奇动效的卡片切换视图","archived":false,"fork":false,"pushed_at":"2020-12-11T07:58:41.000Z","size":14074,"stargazers_count":1733,"open_issues_count":1,"forks_count":204,"subscribers_count":42,"default_branch":"master","last_synced_at":"2024-10-29T17:42:05.816Z","etag":null,"topics":["android","android-card","android-card-animation","android-card-view","animation","card","cardview"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BakerJQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-17T08:24:05.000Z","updated_at":"2024-10-22T09:30:33.000Z","dependencies_parsed_at":"2022-07-31T15:39:01.341Z","dependency_job_id":null,"html_url":"https://github.com/BakerJQ/Android-InfiniteCards","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BakerJQ%2FAndroid-InfiniteCards","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BakerJQ%2FAndroid-InfiniteCards/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BakerJQ%2FAndroid-InfiniteCards/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BakerJQ%2FAndroid-InfiniteCards/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BakerJQ","download_url":"https://codeload.github.com/BakerJQ/Android-InfiniteCards/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223839186,"owners_count":17211889,"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":["android","android-card","android-card-animation","android-card-view","animation","card","cardview"],"created_at":"2024-08-02T01:01:38.381Z","updated_at":"2024-11-09T14:31:12.498Z","avatar_url":"https://github.com/BakerJQ.png","language":"Java","readme":"# InfiniteCards\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n[![](https://jitpack.io/v/BakerJQ/Android-InfiniteCards.svg)](https://jitpack.io/#BakerJQ/Android-InfiniteCards)\n\nAn infinite card switching UI for Android, support custom animation  \n可自定义动效的卡片切换视图（[中文文档](https://github.com/BakerJQ/Android-InfiniteCards/blob/master/README_cn.md)）\n\n## Flutter version\nhttps://github.com/BakerJQ/Flutter-InfiniteCards\n\n## Screenshot\n![](https://raw.githubusercontent.com/BakerJQ/Android-InfiniteCards/master/screenshot/sample.gif)\n\n## Gradle via JitPack\nAdd it in your root build.gradle at the end of repositories:\n``` groovy\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url 'https://jitpack.io' }\n\t}\n}\n```\nAdd the dependency\n``` groovy\ndependencies {\n    implementation 'com.github.BakerJQ:Android-InfiniteCards:1.0.5'\n}\n```\n\n## Attrs\n- animType : animation type\n  - front : move the selected card to first\n  - switchPosition : move the selected card to first, and the first card to the selected position\n  - frontToLast : move the first card to last position\n- cardRatio : ratio of the card\n- animDuration : duration of each card's animation\n- animAddRemoveDelay : delay of animation of add and remove between each card\n- animAddRemoveDuration : duration of add and remove each card's animation\n\n## How to use\n### layout in xml\n```xml\n\u003ccom.bakerj.infinitecards.InfiniteCardView\n        android:id=\"@+id/view\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        infiniteCard:animDuration=\"1000\"\n        infiniteCard:cardRatio=\"1\"/\u003e\n\n```\n### Set Adapter\nJust extends the BaseAdapter\n```java\nclass MyAdapter extends BaseAdapter{\n  ...\n}\nmAdapter = new MyAdapter(resId);\nmCardView.setAdapter(mAdapter);\n```\n### Animation transformers and interpolators\n#### Default\nIf you just use all default animations, just do nothing.\n```java\nmCardView.setAnimInterpolator(new LinearInterpolator());\nmCardView.setTransformerToFront(new DefaultTransformerToFront());\nmCardView.setTransformerToBack(new DefaultTransformerToBack());\nmCardView.setZIndexTransformerToBack(new DefaultZIndexTransformerCommon());\n```\n#### Customisation\n```java\nmCardView.setTransformerToBack(new AnimationTransformer() {\n    @Override\n    public void transformAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {\n        int positionCount = fromPosition - toPosition;\n        float scale = (0.8f - 0.1f * fromPosition) + (0.1f * fraction * positionCount);\n        ViewHelper.setScaleX(view, scale);\n        ViewHelper.setScaleY(view, scale);\n        if (fraction \u003c 0.5) {\n            ViewCompat.setRotationX(view, 180 * fraction);\n        } else {\n            ViewCompat.setRotationX(view, 180 * (1 - fraction));\n        }\n    }\n\n    @Override\n    public void transformInterpolatedAnimation(View view, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {\n        int positionCount = fromPosition - toPosition;\n        float scale = (0.8f - 0.1f * fromPosition) + (0.1f * fraction * positionCount);\n        ViewHelper.setTranslationY(view, -cardHeight * (0.8f - scale) * 0.5f - cardWidth * (0.02f *\n                fromPosition - 0.02f * fraction * positionCount));\n    }\n});\nmCardView.setZIndexTransformerToBack(new ZIndexTransformer() {\n    @Override\n    public void transformAnimation(CardItem card, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {\n        if (fraction \u003c 0.4f) {\n            card.zIndex = 1f + 0.01f * fromPosition;\n        } else {\n            card.zIndex = 1f + 0.01f * toPosition;\n        }\n    }\n\n    @Override\n    public void transformInterpolatedAnimation(CardItem card, float fraction, int cardWidth, int cardHeight, int fromPosition, int toPosition) {\n\n    }\n});\n```\n## *License*\n\nInfiniteCards is released under the Apache 2.0 license.\n\n```\nCopyright 2017 BakerJ.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at following link.\n\n     http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","funding_links":[],"categories":["Card","Library"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBakerJQ%2FAndroid-InfiniteCards","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBakerJQ%2FAndroid-InfiniteCards","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBakerJQ%2FAndroid-InfiniteCards/lists"}