仿饿了么加入购物车旋转控件 - 自带闪转腾挪动画 的按钮。

AnimShopButton

项目地址: mcxtzhang/AnimShopButton
简介:仿饿了么加入购物车旋转控件 - 自带闪转腾挪动画 的按钮。自带海量可定制 UI 属性。在 RecyclerView 中使用,切换 LayoutManager 也是没有问题的
更多: 作者    提 Bug    示例 APK   
标签:
动画- 自定义View- 购物车- 饿了么-

A shopping cart button with a telescopic displacement rotation animation ...

一个仿饿了么 带伸缩位移旋转动画的购物车按钮

注意,本控件非继承自ViewGroup,而是纯自定义 View,实现的仿饿了么加入购物车控件,自带闪转腾挪动画的按钮。

图 1 项目中使用的效果,考虑到了View回收复用

并且可以看到在RecyclerView中使用,切换LayoutManager也是没有问题的,

项目中使用的效果

图 2 Demo 效果,测试各种属性值

图 2 Demo 效果,测试各种属性值

图 3 最新静态图

图 3 最新静态图,测试各种属性值

Article

相关博文:

http://blog.csdn.net/zxt0601/article/details/54235736

想经济上支持我 or 想通过视频看我是怎么实现的:

http://edu.csdn.net/course/detail/3898

Import

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'
    }

Usage

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.

Attributes

nameformatdescription中文解释
isAddFillModebooleanPlus button is opened Fill mode default is stroke (false)加按钮是否开启 fill 模式 默认是 stroke(false)
addEnableBgColorcolorThe background color of the plus button加按钮的背景色
addEnableFgColorcolorThe foreground color of the plus button加按钮的前景色
addDisableBgColorcolorThe background color when the button is not available加按钮不可用时的背景色
addDisableFgColorcolorThe foreground color when the button is not available加按钮不可用时的前景色
isDelFillModebooleanPlus button is opened Fill mode default is stroke (false)减按钮是否开启 fill 模式 默认是 stroke(false)
delEnableBgColorcolorThe background color of the minus button减按钮的背景色
delEnableFgColorcolorThe foreground color of the minus button减按钮的前景色
delDisableBgColorcolorThe background color when the button is not available减按钮不可用时的背景色
delDisableFgColorcolorThe foreground color when the button is not available减按钮不可用时的前景色
radiusdimensionThe radius of the circle圆的半径
circleStrokeWidthdimensionThe width of the circle圆圈的宽度
lineWidthdimensionThe width of the line (+ - sign)线(+ - 符号)的宽度
gapBetweenCircledimensionThe spacing between two circles两个圆之间的间距
numTextSizedimensionThe textSize of draws the number绘制数量的 textSize
maxCountintegermax count最大数量
countintegercurrent count当前数量
hintTextstringThe hint text when number is 0数量为 0 时,hint 文字
hintBgColorcolorThe hint background when number is 0数量为 0 时,hint 背景色
hintFgColorcolorThe hint foreground when number is 0数量为 0 时,hint 前景色
hingTextSizedimensionThe hint text size when number is 0数量为 0 时,hint 文字大小
hintBgRoundValuedimensionThe background fillet value when number is 0数量为 0 时,hint 背景圆角值
ignoreHintAreabooleanThe UI/animation whether ignores the hint areaUI 显示、动画是否忽略 hint 收缩区域
perAnimDurationintegerThe duration of each animation, in ms每一段动画的执行时间,单位 ms
hintTextstringThe hint text when number is 0数量为 0 时,hint 文字
replenishTextColorcolorTextColor in replenish status补货中状态的文字颜色
replenishTextSizedimensionTextSize in replenish status补货中状态的文字大小
replenishTextstringText hint in replenish status补货中状态的文字

这么多属性够你用了吧。

Where to find me:

Github

CSDN

稀土掘金

简书

QQ 群 :557266366


History

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 ()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值