逢魔林怎么去,我的答铃英文版,安徽省太和县
android color颜色过度计算实现代码
在看自定义typeevaluator来计算属性动画的属性值时,用到了对颜色的过度计算,翻看了好多博客,找到了比较有优秀的解决方案,在此记录,以备后用。
实现效果图:
实现代码:
/** * 根据fraction值来计算当前的颜色。 */ private int getcurrentcolor(float fraction, int startcolor, int endcolor) { int redcurrent; int bluecurrent; int greencurrent; int alphacurrent; int redstart = color.red(startcolor); int bluestart = color.blue(startcolor); int greenstart = color.green(startcolor); int alphastart = color.alpha(startcolor); int redend = color.red(endcolor); int blueend = color.blue(endcolor); int greenend = color.green(endcolor); int alphaend = color.alpha(endcolor); int reddifference = redend - redstart; int bluedifference = blueend - bluestart; int greendifference = greenend - greenstart; int alphadifference = alphaend - alphastart; redcurrent = (int) (redstart + fraction * reddifference); bluecurrent = (int) (bluestart + fraction * bluedifference); greencurrent = (int) (greenstart + fraction * greendifference); alphacurrent = (int) (alphastart + fraction * alphadifference); return color.argb(alphacurrent, redcurrent, greencurrent, bluecurrent); }
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Android apk 项目一键打包并上传到蒲公英的实现方法
Android 自定义LineLayout实现满屏任意拖动功能的示例代码
android 限制某个操作每天只能操作指定的次数(示例代码详解)
Android 集成 google 登录并获取性别等隐私信息的实现代码
网友评论