0 Star 0 Fork 3

阿怪先生 / TintImage

forked from 大熊 / TintImage 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
大熊 提交于 2016-04-22 18:05 . Update README.md

#效果图

输入图片说明 输入图片说明 输入图片说明

#核心代码

/**
     * 实现ImageView的变色
     *
     * @param imageView
     * @param color
     */
    public static void setTint(@NonNull ImageView imageView, @ColorInt int color) {
        ColorStateList s1 = ColorStateList.valueOf(color);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            imageView.setImageTintList(s1);
        } else {
            PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
                mode = PorterDuff.Mode.MULTIPLY;
            }
            if (imageView.getDrawable() != null)
                imageView.getDrawable().setColorFilter(color, mode);
        }
    }
1
https://gitee.com/1234414/TintImage.git
git@gitee.com:1234414/TintImage.git
1234414
TintImage
TintImage
master

搜索帮助