A shopping cart button with a telescopic displacement rotation animation ...
一个仿饿了么 带伸缩位移旋转动画的购物车按钮
注意,本控件非继承自ViewGroup,而是纯自定义View,实现的仿饿了么加入购物车控件,自带闪转腾挪动画的按钮。
图1 项目中使用的效果,考虑到了View的回收复用,
并且可以看到在RecyclerView中使用,切换LayoutManager也是没有问题的,
图2 Demo效果,测试各种属性值
图3 最新静态图
相关博文:
http://blog.csdn.net/zxt0601/article/details/54235736
想经济上支持我 or 想通过视频看我是怎么实现的:
http://edu.csdn.net/course/detail/3898
Step 1. Add the JitPack repository to your build file
Step 1. 在项目根build.gradle文件中增加JitPack仓库依赖。
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
Step 2. Add the dependency
dependencies {
compile 'com.github.mcxtzhang:AnimShopButton:V1.2.0'
}
xml:
<!--使用默认UI属性-->
<com.mcxtzhang.lib.AnimShopButton
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:maxCount="3"/>
<!--设置了两圆间距-->
<com.mcxtzhang.lib.AnimShopButton
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:count="3"
app:gapBetweenCircle="90dp"
app:maxCount="99"/>
<!--仿饿了么-->
<com.mcxtzhang.lib.AnimShopButton
android:id="@+id/btnEle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:addEnableBgColor="#3190E8"
app:addEnableFgColor="#ffffff"
app:hintBgColor="#3190E8"
app:hintBgRoundValue="15dp"
app:hintFgColor="#ffffff"
app:maxCount="99"/>
注意: 加减点击后,具体的操作,要根据业务的不同来编写了,设计到实际的购物车可能还有写数据库操作,或者请求接口等,要操作成功后才执行动画、或者修改count,这一块代码每个人写法可能不同。
使用时,可以重写onDelClick()和 onAddClick()方法,并在合适的时机回调onCountAddSuccess()和 onCountDelSuccess()以执行动画。
效果图如图2.
QQ群 :557266366
Version : 1.1.0,Time: 2017/01/12
- 1 Feature : Add a boolean variable
ignoreHintArea:The UI/animation whether ignores the hint area - 2 Feature : Add a int variable
perAnimDuration: The duration of each animation, in ms
Version : 1.2.0 Time: 2017/02/08
- 1 Feature : Add a status: replenishment.Click is not allowed at this time.
- Judgment by setReplenish (boolean) and isReplenish ()



