{"id":13639450,"url":"https://github.com/mcxtzhang/AnimShopButton","last_synced_at":"2025-04-19T22:32:46.387Z","repository":{"id":112692480,"uuid":"77523080","full_name":"mcxtzhang/AnimShopButton","owner":"mcxtzhang","description":"A shopping cart button with a telescopic displacement rotation animation ...一个带伸缩位移旋转动画的购物车按钮","archived":false,"fork":false,"pushed_at":"2017-11-18T14:53:53.000Z","size":5045,"stargazers_count":1297,"open_issues_count":11,"forks_count":182,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-04-12T18:53:42.228Z","etag":null,"topics":["animation","ele","shopping-cart-button"],"latest_commit_sha":null,"homepage":"http://blog.csdn.net/zxt0601/article/details/54235736","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/mcxtzhang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-12-28T10:05:53.000Z","updated_at":"2025-01-22T07:33:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"c8f180a4-27b3-4170-8d7a-79b733945dcb","html_url":"https://github.com/mcxtzhang/AnimShopButton","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxtzhang%2FAnimShopButton","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxtzhang%2FAnimShopButton/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxtzhang%2FAnimShopButton/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcxtzhang%2FAnimShopButton/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcxtzhang","download_url":"https://codeload.github.com/mcxtzhang/AnimShopButton/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249822206,"owners_count":21329935,"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":["animation","ele","shopping-cart-button"],"created_at":"2024-08-02T01:01:00.707Z","updated_at":"2025-04-19T22:32:44.173Z","avatar_url":"https://github.com/mcxtzhang.png","language":"Java","readme":"# AnimShopButton\n[![](https://jitpack.io/v/mcxtzhang/AnimShopButton.svg)](https://jitpack.io/#mcxtzhang/AnimShopButton)\n\nA shopping cart button with a telescopic displacement rotation animation ...\n\n一个仿饿了么 带伸缩位移旋转动画的购物车按钮\n\n注意，本控件非继承自`ViewGroup`,而是**纯自定义View**，实现的仿饿了么加入购物车控件，自带**闪转腾挪动画**的按钮。\n\n\n图1 项目中使用的效果，考虑到了`View`的**回收复用**，\n\n并且可以看到在`RecyclerView`中使用，切换`LayoutManager`也是没有问题的，\n\n![项目中使用的效果](https://github.com/mcxtzhang/AnimShopButton/blob/master/gif/new.gif)\n\n图2 Demo效果，测试各种属性值\n\n![图2 Demo效果，测试各种属性值](https://github.com/mcxtzhang/AnimShopButton/blob/master/gif/testAttr.gif)\n\n图3 最新静态图\n\n![图3 最新静态图，测试各种属性值](https://github.com/mcxtzhang/AnimShopButton/blob/master/gif/attrs.png)\n\n\n# Article\n相关博文：\n\nhttp://blog.csdn.net/zxt0601/article/details/54235736\n\n想经济上支持我 or 想通过视频看我是怎么实现的:\n\nhttp://edu.csdn.net/course/detail/3898\n\n# Import\n**Step 1. Add the JitPack repository to your build file**\n\n**Step 1. 在项目根build.gradle文件中增加JitPack仓库依赖。** \n```\n    allprojects {\n\t\trepositories {\n\t\t\t...\n\t\t\tmaven { url \"https://jitpack.io\" }\n\t\t}\n\t}\n```\nStep 2. Add the dependency\n```\n    dependencies {\n\t        compile 'com.github.mcxtzhang:AnimShopButton:V1.2.0'\n\t}\n```\n\n# Usage\n xml:\n\n\n```\n\t\u003c!--使用默认UI属性--\u003e\n    \u003ccom.mcxtzhang.lib.AnimShopButton\n        android:id=\"@+id/btn1\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        app:maxCount=\"3\"/\u003e\n    \u003c!--设置了两圆间距--\u003e\n    \u003ccom.mcxtzhang.lib.AnimShopButton\n        android:id=\"@+id/btn2\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        app:count=\"3\"\n        app:gapBetweenCircle=\"90dp\"\n        app:maxCount=\"99\"/\u003e\n    \u003c!--仿饿了么--\u003e\n    \u003ccom.mcxtzhang.lib.AnimShopButton\n        android:id=\"@+id/btnEle\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        app:addEnableBgColor=\"#3190E8\"\n        app:addEnableFgColor=\"#ffffff\"\n        app:hintBgColor=\"#3190E8\"\n        app:hintBgRoundValue=\"15dp\"\n        app:hintFgColor=\"#ffffff\"\n        app:maxCount=\"99\"/\u003e\n```\n\n注意：\n加减点击后，具体的操作，要根据业务的不同来编写了，设计到实际的购物车可能还有写数据库操作，或者请求接口等，要操作成功后才执行动画、或者修改count，这一块代码每个人写法可能不同。\n\n使用时，可以重写`onDelClick()`和` onAddClick()`方法，并在合适的时机回调`onCountAddSuccess()`和` onCountDelSuccess()`以执行动画。\n\n效果图如图2.\n\n# Attributes\n|name|format|description|中文解释\n|:---:|:---:|:---:|:---:|\n| isAddFillMode| boolean| Plus button is opened Fill mode default is stroke (false)|加按钮是否开启fill模式 默认是stroke(false)\n| addEnableBgColor| color|The background color of the plus button|加按钮的背景色\n| addEnableFgColor| color|The foreground color of the plus button|加按钮的前景色\n| addDisableBgColor| color|The background color when the button is not available|加按钮不可用时的背景色\n| addDisableFgColor| color |The foreground color when the button is not available|加按钮不可用时的前景色\n| isDelFillMode| boolean| Plus button is opened Fill mode default is stroke (false)|减按钮是否开启fill模式 默认是stroke(false)\n| delEnableBgColor| color|The background color of the minus button|减按钮的背景色\n| delEnableFgColor| color|The foreground color of the minus button|减按钮的前景色\n| delDisableBgColor| color|The background color when the button is not available|减按钮不可用时的背景色\n| delDisableFgColor| color |The foreground color when the button is not available|减按钮不可用时的前景色\n| radius| dimension|The radius of the circle|圆的半径\n| circleStrokeWidth| dimension|The width of the circle|圆圈的宽度\n| lineWidth| dimension|The width of the line (+ - sign)|线(+ - 符号)的宽度\n| gapBetweenCircle| dimension| The spacing between two circles|两个圆之间的间距\n| numTextSize| dimension| The textSize of draws the number|绘制数量的textSize\n| maxCount| integer| max count|最大数量\n| count| integer| current count|当前数量\n| hintText| string| The hint text when number is 0|数量为0时，hint文字\n| hintBgColor| color| The hint background when number is 0|数量为0时，hint背景色\n| hintFgColor| color| The hint foreground when number is 0|数量为0时，hint前景色\n| hingTextSize| dimension| The hint text size when number is 0|数量为0时，hint文字大小\n| hintBgRoundValue| dimension| The background fillet value when number is 0|数量为0时，hint背景圆角值\n| ignoreHintArea| boolean| The UI/animation whether ignores the hint area|UI显示、动画是否忽略hint收缩区域\n| perAnimDuration| integer| The duration of each animation, in ms|每一段动画的执行时间，单位ms\n| hintText| string| The hint text when number is 0|数量为0时，hint文字\n| replenishTextColor| color| TextColor in replenish status|补货中状态的文字颜色\n| replenishTextSize| dimension| TextSize in replenish status|补货中状态的文字大小\n| replenishText| string | Text hint in replenish status|补货中状态的文字\n这么多属性够你用了吧。\n\n\n## Where to find me:\n\n[Github](https://github.com/mcxtzhang)\n\n[CSDN](http://blog.csdn.net/zxt0601)\n\n[稀土掘金](http://gold.xitu.io/user/56de210b816dfa0052e66495)\n\n[简书](http://www.jianshu.com/users/8e91ff99b072/timeline)\n\nQQ群 ：**557266366**\n***\n\n## History\nVersion : 1.1.0,Time: 2017/01/12\n * 1 Feature : Add a boolean variable `ignoreHintArea` ：The UI/animation whether ignores the hint area\n * 2 Feature : Add a int variable `perAnimDuration` : The duration of each animation, in ms\n\nVersion : 1.2.0 Time: 2017/02/08\n * 1 Feature : Add a status: replenishment.Click is not allowed at this time.\n * Judgment by setReplenish (boolean) and isReplenish ()\n\n\n\n","funding_links":[],"categories":["按钮"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcxtzhang%2FAnimShopButton","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcxtzhang%2FAnimShopButton","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcxtzhang%2FAnimShopButton/lists"}