开源项目: 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 ...
随机推荐
- 做一名开源社区的扫地僧——从Bug report到Google Summer of Code(GSoC):从200个bug到5000美金
今年的软件自由日(SFD),我在广州Linux用户组的线下活动上做了一个分享,主题叫做<做一名开源社区的扫地僧(上)>.我把演讲的内容重新整理扩充, 写出了文字版, 希望可以跟更多朋友分享 ...
- 剖析JSONP原理的小例子
1. 服务器端代码(Node.js) // 导入 http 内置模块 const http = require('http'); // 这个核心模块,能够帮我们解析 URL地址,从而拿到 pathna ...
- VS2010在WIN7下安装报错“下列组件安装失败”如何解决
VS2010在WIN7下安装报错“下列组件安装失败”如何解决 http://www.111cn.net/net/42/75914.htm
- vijosP1286座位安排(状压DP)
传送门 题意 计算\(C_{n*m}^k/可行方案数\) 分析 定义dp[i][j][k]为第i行用过人数为j个且第i行状态为k的方案数 转移方程:dp[i][j][k]=Σdp[i-1][j-num ...
- 一个Java语言所写的shop网站框架明细
核心框架Spring Framework :作为一个优秀的开源框架,是为了解决企业应用程序开发复杂性而创建的.框架的主要优势之一就是其分层架构,分层架构允许您选择使用哪一个组件,同时为 J2EE 应用 ...
- Android近场通信---NFC基础(一)(转)
转自 http://blog.csdn.net/think_soft/article/details/8169483 本文译自:http://developer.android.com/guide/t ...
- Location replace() 方法
replace() 方法可用一个新文档取代当前文档. <!DOCTYPE html> <html> <head> <meta charset="ut ...
- AtCoder Beginner Contest 051 ABCD题
A - Haiku Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement As a New Yea ...
- Java三种技术架构
http://blog.csdn.net/weixin_36416990/article/details/52845868
- 图像处理库CImg
CImg 是一个用C++编写的开源数字图像处理库. 作者介绍 作者David Tschumperlé, 之前是法国La Rochelle大学的一名教授,现受雇于CNRS 图像组.据说作者从19 ...