ViewUtils.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:MaterialStepperView 作者:
static ObjectAnimator createArgbAnimator(View view, String propertyName, int startColor, int endColor) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return ObjectAnimator.ofObject(view, propertyName, new TypeEvaluator() {
            @Override
            public Object evaluate(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;

                return (startA + (int)(fraction * (endA - startA))) << 24 |
                        (startR + (int)(fraction * (endR - startR))) << 16 |
                        (startG + (int)(fraction * (endG - startG))) << 8 |
                        (startB + (int)(fraction * (endB - startB)));
            }
        }, startColor, endColor);
    } else {
        return ObjectAnimator.ofArgb(view, propertyName, startColor, endColor);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号