android按钮变输入框动画,AnimShopButton 仿饿了么加入购物车旋转控件 - 自带闪转腾挪动画 的按钮。自带海量可定制 UI 属性。在 Re @codeKK Android开源站...
A shopping cart button with a telescopic displacement rotation animation ...
一個(gè)仿餓了么 帶伸縮位移旋轉(zhuǎn)動(dòng)畫的購物車按鈕
注意,本控件非繼承自ViewGroup,而是純自定義 View,實(shí)現(xiàn)的仿餓了么加入購物車控件,自帶閃轉(zhuǎn)騰挪動(dòng)畫的按鈕。
圖 1 項(xiàng)目中使用的效果,考慮到了View的回收復(fù)用,
并且可以看到在RecyclerView中使用,切換LayoutManager也是沒有問題的,
圖 2 Demo 效果,測(cè)試各種屬性值
圖 3 最新靜態(tài)圖
Article
相關(guān)博文:
想經(jīng)濟(jì)上支持我 or 想通過視頻看我是怎么實(shí)現(xiàn)的:
Import
Step 1. Add the JitPack repository to your build file
Step 1. 在項(xiàng)目根 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:
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:maxCount="3"/>
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:count="3"
app:gapBetweenCircle="90dp"
app:maxCount="99"/>
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"/>
注意:
加減點(diǎn)擊后,具體的操作,要根據(jù)業(yè)務(wù)的不同來編寫了,設(shè)計(jì)到實(shí)際的購物車可能還有寫數(shù)據(jù)庫操作,或者請(qǐng)求接口等,要操作成功后才執(zhí)行動(dòng)畫、或者修改 count,這一塊代碼每個(gè)人寫法可能不同。
使用時(shí),可以重寫onDelClick()和onAddClick()方法,并在合適的時(shí)機(jī)回調(diào)onCountAddSuccess()和onCountDelSuccess()以執(zhí)行動(dòng)畫。
效果圖如圖 2.
Attributes
name
format
description
中文解釋
isAddFillMode
boolean
Plus button is opened Fill mode default is stroke (false)
加按鈕是否開啟 fill 模式 默認(rèn)是 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
加按鈕不可用時(shí)的背景色
addDisableFgColor
color
The foreground color when the button is not available
加按鈕不可用時(shí)的前景色
isDelFillMode
boolean
Plus button is opened Fill mode default is stroke (false)
減按鈕是否開啟 fill 模式 默認(rèn)是 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
減按鈕不可用時(shí)的背景色
delDisableFgColor
color
The foreground color when the button is not available
減按鈕不可用時(shí)的前景色
radius
dimension
The radius of the circle
圓的半徑
circleStrokeWidth
dimension
The width of the circle
圓圈的寬度
lineWidth
dimension
The width of the line (+ - sign)
線(+ - 符號(hào))的寬度
gapBetweenCircle
dimension
The spacing between two circles
兩個(gè)圓之間的間距
numTextSize
dimension
The textSize of draws the number
繪制數(shù)量的 textSize
maxCount
integer
max count
最大數(shù)量
count
integer
current count
當(dāng)前數(shù)量
hintText
string
The hint text when number is 0
數(shù)量為 0 時(shí),hint 文字
hintBgColor
color
The hint background when number is 0
數(shù)量為 0 時(shí),hint 背景色
hintFgColor
color
The hint foreground when number is 0
數(shù)量為 0 時(shí),hint 前景色
hingTextSize
dimension
The hint text size when number is 0
數(shù)量為 0 時(shí),hint 文字大小
hintBgRoundValue
dimension
The background fillet value when number is 0
數(shù)量為 0 時(shí),hint 背景圓角值
ignoreHintArea
boolean
The UI/animation whether ignores the hint area
UI 顯示、動(dòng)畫是否忽略 hint 收縮區(qū)域
perAnimDuration
integer
The duration of each animation, in ms
每一段動(dòng)畫的執(zhí)行時(shí)間,單位 ms
hintText
string
The hint text when number is 0
數(shù)量為 0 時(shí),hint 文字
replenishTextColor
color
TextColor in replenish status
補(bǔ)貨中狀態(tài)的文字顏色
replenishTextSize
dimension
TextSize in replenish status
補(bǔ)貨中狀態(tài)的文字大小
replenishText
string
Text hint in replenish status
補(bǔ)貨中狀態(tài)的文字
這么多屬性夠你用了吧。
Where to find me:
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 ()
總結(jié)
以上是生活随笔為你收集整理的android按钮变输入框动画,AnimShopButton 仿饿了么加入购物车旋转控件 - 自带闪转腾挪动画 的按钮。自带海量可定制 UI 属性。在 Re @codeKK Android开源站...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 雨课堂显示服务器无法连接,雨课堂用的什么
- 下一篇: 添加mysql至服务器_mysql 如何