A shopping cart button with a telescopic displacement rotation animation ...一个带伸缩位移旋转动画的购物车按钮

Overview

AnimShopButton

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

name format description 中文解释
isAddFillMode boolean Plus button is opened Fill mode default is stroke (false) 加按钮是否开启fill模式 默认是stroke(false)
addEnableBgColor color The background color of the plus button 加按钮的背景色
addEnableFgColor color The foreground color of the plus button 加按钮的前景色
addDisableBgColor color The background color when the button is not available 加按钮不可用时的背景色
addDisableFgColor color The foreground color when the button is not available 加按钮不可用时的前景色
isDelFillMode boolean Plus button is opened Fill mode default is stroke (false) 减按钮是否开启fill模式 默认是stroke(false)
delEnableBgColor color The background color of the minus button 减按钮的背景色
delEnableFgColor color The foreground color of the minus button 减按钮的前景色
delDisableBgColor color The background color when the button is not available 减按钮不可用时的背景色
delDisableFgColor color The foreground color when the button is not available 减按钮不可用时的前景色
radius dimension The radius of the circle 圆的半径
circleStrokeWidth dimension The width of the circle 圆圈的宽度
lineWidth dimension The width of the line (+ - sign) 线(+ - 符号)的宽度
gapBetweenCircle dimension The spacing between two circles 两个圆之间的间距
numTextSize dimension The textSize of draws the number 绘制数量的textSize
maxCount integer max count 最大数量
count integer current count 当前数量
hintText string The hint text when number is 0 数量为0时,hint文字
hintBgColor color The hint background when number is 0 数量为0时,hint背景色
hintFgColor color The hint foreground when number is 0 数量为0时,hint前景色
hingTextSize dimension The hint text size when number is 0 数量为0时,hint文字大小
hintBgRoundValue dimension The background fillet value when number is 0 数量为0时,hint背景圆角值
ignoreHintArea boolean The UI/animation whether ignores the hint area UI显示、动画是否忽略hint收缩区域
perAnimDuration integer The duration of each animation, in ms 每一段动画的执行时间,单位ms
hintText string The hint text when number is 0 数量为0时,hint文字
replenishTextColor color TextColor in replenish status 补货中状态的文字颜色
replenishTextSize dimension TextSize in replenish status 补货中状态的文字大小
replenishText string Text 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 ()
You might also like...
Button which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK).
Button which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK).

HoldingButton Button which is visible while user holds it. Main use case is controlling audio recording state (like in Telegram, Viber, VK). Getting s

[] An Android library for an expandable button menu
[] An Android library for an expandable button menu

ExpandableButtonMenu ExpandableButtonMenu is an Android library which implements an expandable button that can be used as a substitute of a fixed size

This is a Material Design loading button

This is a library project with a custom view that implements concept of Send Comment (https://dribbble.com/shots/1986254-Send-Comment-Shoppr) made by

comtomize view submit button which you use for submit operation or download operation and so on.
comtomize view submit button which you use for submit operation or download operation and so on.

This is library project with a custom view that implements concept of Submit Button (https://dribbble.com/shots/1426764-Submit-Button?list=likes&offse

A raised button that lowers down to 0dp of elevation
A raised button that lowers down to 0dp of elevation

RaiflatButton A raised button that lowers down to 0dp of elevation. From my blog post: https://rubensousa.github.io/2016/10/raiflatbutton It behaves l

Kotlin Expanding Floating Action button
Kotlin Expanding Floating Action button

Kotlin-Expanding-Floating-Action_button Home Screen As you can see there is only a siongle floating button with + icon Expanding Fab button When we cl

Android library providing an implementation of the Material Design Floating Action Button Speed Dial.
Android library providing an implementation of the Material Design Floating Action Button Speed Dial.

Android library providing an implementation of the Material Design Floating Action Button Speed Dial.

Floating Action Button But Moveable And Expandalbe

MeFab todo add the maven bacge here Floating Action Button but MOVEABLE and EXPA

➕ An efficient and beaufitul Multi Float action button library based on Twitter implemented in Jetpack Compose 🚀
➕ An efficient and beaufitul Multi Float action button library based on Twitter implemented in Jetpack Compose 🚀

Multi Float Action Button ➕ An efficient and beaufitul Multi Float action button library based on Twitter implemented in Jetpack Compose 🚀 Including

Comments
  • 在recyclerview中重新刷新数据时setCount数量不变或是错乱

    在recyclerview中重新刷新数据时setCount数量不变或是错乱

    首页界面viewpager中有3个fragment,fragment中用recyclerView显示商品列表,当在购物车编辑购买数量后用 EventBus 通知首页刷新商品列表,打log发现数据有改变,但 AnimShopButton中的数量确没变化,一开始还以为是 notifyDataSetChanged() 无效,但测试发现界面刷新了,但 AnimShopButton 数量还是没改变。

    之前还碰到过,在商品列表中添加或减少购买数量,其他商品的 AnimShopButton 数量跟着改变,数字错乱

    opened by KXwonderful 3
A download button with pretty cool animation

ArrowDownloadButton A download button with pretty cool animation, this is an implemention of https://dribbble.com/shots/2012292-Download-Animation Enj

Rongchan Liu 967 Oct 16, 2022
Android Circular Progress Button

?? Before using this library, read information below ?? This library is not more supported. If you want to add new feature or fix a bug, grab source

Dmytro Danylyk 5.6k Nov 22, 2022
Circle button widget for Android

DEPRECATED This library is deprecated and no new development is taking place. Consider using a FAB(Floating action button) instead. E.g. the Android D

Markus Hintersteiner 1.5k Nov 26, 2022
FButton - a flat button library for Android

FButton FButton is a custom Button of Android with "Flat UI" concept. FButton's design get inspiration from designmono. This library is very small and

Le Van Hoang 1.4k Nov 17, 2022
Android button which moves in eight direction.

Moving Button Android button which moves in eight direction. Preview Sample Demo You can download demo movie file here : demo.mov It's also on Youtube

Leonardo Taehwan Kim 131 Nov 16, 2022
Button for android with animations for transition and error states.

Transition Button Android Preview Expand animation: Shake animation: Installation Gradle dependencies { implementation 'com.royrodriguez:transitionbu

Roy Rodriguez 133 Dec 1, 2022
[] Android floating action button

DEPRECATED Use the FloatingActionButton from the support library instead. FloatingActionButton Description Android floating action button which reacts

Oleksandr Melnykov 4k Nov 19, 2022
Floating Action Button for Android based on Material Design specification

FloatingActionButton Yet another library for drawing Material Design promoted actions. Features Support for normal 56dp and mini 40dp buttons. Customi

Zendesk 6.4k Nov 21, 2022
A cute widget of Switch Button for you to create beautiful and friendly UI.

SwitchButton To get a quick preview, you can get Demo apk in Google Play or Directly download. This project provides you a convenient way to use and c

kyleduo 4.6k Nov 18, 2022
A simple Floating Action Button that shows an anchored Navigation View

Floating Navigation View A simple Floating Action Button that shows an anchored Navigation View and was inspired by Menu Material Fixed created by Tom

André Mion 1.3k Nov 18, 2022