国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Android > 正文

Android Color顏色過度計算實現代碼

2019-10-23 18:27:05
字體:
來源:轉載
供稿:網友

Android Color顏色過度計算實現代碼

在看自定義TypeEvaluator來計算屬性動畫的屬性值時,用到了對顏色的過度計算,翻看了好多博客,找到了比較有優秀的解決方案,在此記錄,以備后用。

實現效果圖:

Android,Color顏色過度計算,Color顏色

實現代碼:

/** * 根據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開發頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 涞源县| 进贤县| 铁岭县| 通化县| 赣榆县| 苍溪县| 东乡族自治县| 肃北| 大冶市| 阳信县| 东平县| 绥宁县| 云龙县| 泸州市| 镇康县| 沙坪坝区| 三都| 区。| 孝昌县| 洛南县| 乐昌市| 西和县| 云霄县| 平塘县| 博客| 赣榆县| 无为县| 永州市| 新蔡县| 雷波县| 英德市| 肇源县| 阿巴嘎旗| 黄山市| 大城县| 靖西县| 乡城县| 葫芦岛市| 永登县| 区。| 富源县|