GithubHelp home page GithubHelp logo

chinavolvocars / animshopbutton Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mcxtzhang/animshopbutton

0.0 1.0 0.0 4.84 MB

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

License: Apache License 2.0

Java 100.00%

animshopbutton's Introduction

AnimShopButton

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

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

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

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

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

项目中使用的效果

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

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

Article

相关博文:

todo

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.0.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背景圆角值

这么多属性够你用了吧。

Where to find me:

Github

CSDN

稀土掘金

简书

QQ群 :557266366


animshopbutton's People

Contributors

mcxtzhang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.