开源项目: circular-progress-button
public class CircleButton extends Button implements View.OnClickListener {private StateListDrawable mIdleStateDrawable;private StrokeGradientDrawable background;public CircleButton(Context context, AttributeSet attrs) {super(context, attrs);background = new StrokeGradientDrawable();// init();// setBackground(mIdleStateDrawable);setBackground(background.getGradientDrawable());setOnClickListener(this);}//.......}
public class StrokeGradientDrawable {private int mStrokeColor; //描边颜色private int mStrokeWidth; //描边宽度public int getStrokeColor() {return mStrokeColor;}public void setStrokeColor(int strokeColor) {mStrokeColor = strokeColor;mGradientDrawable.setStroke(getStrokeWidth(), strokeColor);}public int getStrokeWidth() {return mStrokeWidth;}public void setStrokeWidth(int strokeWidth) {mStrokeWidth = strokeWidth;mGradientDrawable.setStroke(strokeWidth, getStrokeColor());}public StrokeGradientDrawable() {mGradientDrawable = new GradientDrawable();mGradientDrawable.setColor(0xff99cc00);mStrokeWidth = 5;}public GradientDrawable getGradientDrawable() {return mGradientDrawable;}public void setmGradientDrawable(GradientDrawable mGradientDrawable) {this.mGradientDrawable = mGradientDrawable;}private GradientDrawable mGradientDrawable;}
@Overridepublic void onClick(View v) {final GradientDrawable gradientDrawable = background.getGradientDrawable();final int mFromWidth = getWidth();final int mToWidth = getHeight();//宽度动画ValueAnimator widthAnimation = ValueAnimator.ofInt(mFromWidth, mToWidth);widthAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {@Overridepublic void onAnimationUpdate(ValueAnimator animation) {Integer value = (Integer) animation.getAnimatedValue();int leftOffset;int rightOffset;int padding;if (mFromWidth > mToWidth) {leftOffset = (mFromWidth - value) / 2;rightOffset = mFromWidth - leftOffset;} else {leftOffset = (mToWidth - value) / 2;rightOffset = mToWidth - leftOffset;}gradientDrawable.setBounds(leftOffset, 0, rightOffset, getHeight());}});//填充颜色ObjectAnimator bgColorAnimation = ObjectAnimator.ofInt(gradientDrawable, "color", 0xff99cc00, Color.WHITE);bgColorAnimation.setEvaluator(new ArgbEvaluator());//描边ObjectAnimator strokeColorAnimation =ObjectAnimator.ofInt(background, "strokeColor", 0xff99cc00, Color.GRAY);strokeColorAnimation.setEvaluator(new ArgbEvaluator());//圆角ObjectAnimator cornerAnimation =ObjectAnimator.ofFloat(gradientDrawable, "cornerRadius", 0, 30);AnimatorSet animatorSet = new AnimatorSet();animatorSet.setDuration(2000);animatorSet.playTogether(bgColorAnimation, cornerAnimation, widthAnimation,strokeColorAnimation);animatorSet.start();}
, IDLE,
,]





开源项目: circular-progress-button的更多相关文章
- 用开源项目circular progress button实现有进度条的Button
circular progress button可以让button实现进度条,效果和动画都做的很赞,只是有点小bug.需要注意的是按钮上的文字不能太大,否则会出现错位. 项目的地址:https://g ...
- Android开源项目发现---TextView,Button篇(持续更新)
android-flowtextview 文字自动环绕其他View的Layout 项目地址:https://code.google.com/p/android-flowtextview/ 效果图:ht ...
- Github上关于iOS的各种开源项目集合(强烈建议大家收藏,查看,总有一款你需要)
下拉刷新 EGOTableViewPullRefresh - 最早的下拉刷新控件. SVPullToRefresh - 下拉刷新控件. MJRefresh - 仅需一行代码就可以为UITableVie ...
- iOS及Mac开源项目和学习资料【超级全面】
UI 下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅需一行代码就可以为UITable ...
- iOS开发--iOS及Mac开源项目和学习资料
文/零距离仰望星空(简书作者)原文链接:http://www.jianshu.com/p/f6cdbc8192ba著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”. 原文出处:codecl ...
- iOS、mac开源项目及库汇总
原文地址:http://blog.csdn.net/qq_26359763/article/details/51076499 iOS每日一记------------之 中级完美大整理 iOS.m ...
- github上关于iOS的各种开源项目集合(转)
UI 下拉刷新 EGOTableViewPullRefresh - 最早的下拉刷新控件. SVPullToRefresh - 下拉刷新控件. MJRefresh - 仅需一行代码就可以为UITable ...
- 分享海量 iOS 及 Mac 开源项目和学习资料
UI 下拉刷新 EGOTableViewPullRefresh - 最早的下拉刷新控件. SVPullToRefresh - 下拉刷新控件. MJRefresh - 仅需一行代码就可以为UITable ...
- iOS -- 开源项目和库
TimLiu-iOS 目录 UI 下拉刷新 模糊效果 AutoLayout 富文本 图表 表相关与Tabbar 隐藏与显示 HUD与Toast 对话框 其他UI 动画 侧滑与右滑返回手势 gif动画 ...
- 最全面的iOS和Mac开源项目和第三方库汇总
标签: UI 下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅需一行代码就可以为UIT ...
随机推荐
- 1-1 课程简介 & 2-1 IDEA与Eclipse的不同 & 2-3 Intellij IDEA安装
---恢复内容开始--- F:\教程\java-慕课\从网页搭建入门Java Web\Java web\步骤四:常用功能\1.IntelliJ IDEA开发工具入门 1-1 课程简介 2-1 IDEA ...
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">详解
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Python3.6 字典的内置方法
1.dict.clear(self) 删除字典内所有元素 2.dict.copy(self) 返回一个字典的浅复制,拷贝父对象,不会拷贝对象的内部的子对象 3.dict.fromkeys(self, ...
- meta标签常用属性
Keywords(关键词) 说明:告诉搜索引擎你网页的关键字(keywords)使用方法:<meta name="keywords" content="标签,属性, ...
- POJ3696【欧拉函数+欧拉定理】
题意: 求最小T,满足L的倍数且都由8组成,求长度: 思路: 很强势的福利:点 图片拿出去食用更优 //#include<bits/stdc++.h> #include<cstdio ...
- jzoj5986. 【WC2019模拟2019.1.4】立体几何题 (权值线段树)
传送门 题面 题解 不难看出每个点的大小为行列限制中较小的那一个(因为数据保证有解) 对于行的每个限制,能取到的个数是列里限制大于等于它的数的个数,同理,对于列是行里大于它的个数(这里没有等于,为了避 ...
- [Xcode 实际操作]九、实用进阶-(10)定位设备的使用
目录:[Swift]Xcode实际操作 本文将演示定位设备的使用. 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit //导入需要用到的定位 ...
- assembly x86(nasm)的日常
cs的日常打卡. data segment ENG db 'SUNdayS Coming I Wanna Drive My Car,SUN,SUN$' ;43,35 sun1 db 'SUN' swc ...
- E - Round Numbers
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> ...
- SpringBoot | 集成Java Mail
Spring Boot 对Java mail 集成提供了自动配置的支持,只需要配置依赖以及在application.properties 里配置邮件信息即可. 添加依赖: <dependency ...