package com.example.administrator.cookman.ui.component.magicindicator.buildins; /** * 实现颜色渐变,考虑到兼容性,不使用内置的ArgbEvaluator * 博客: http://hackware.lucode.net * Created by hackware on 2016/6/26. */ public class ArgbEvaluatorHolder { public static Object eval(float fraction, Object startValue, Object endValue) { int startInt = (Integer) startValue; int startA = (startInt >> 24) & 0xff; int startR = (startInt >> 16) & 0xff; int startG = (startInt >> 8) & 0xff; int startB = startInt & 0xff; int endInt = (Integer) endValue; int endA = (endInt >> 24) & 0xff; int endR = (endInt >> 16) & 0xff; int endG = (endInt >> 8) & 0xff; int endB = endInt & 0xff; int currentA = (startA + (int) (fraction * (endA - startA))) << 24; int currentR = (startR + (int) (fraction * (endR - startR))) << 16; int currentG = (startG + (int) (fraction * (endG - startG))) << 8; int currentB = startB + (int) (fraction * (endB - startB)); return currentA | currentR | currentG | currentB; } }