android代码修改图片颜色

2019-08-08  本文已影响0人  曾经2020

来自https://www.jianshu.com/p/514fbcd7e98d

1432234-141985e0c335ef89.png
imageView.setImageDrawable(tintDrawable(imageView.drawable, ColorStateList.valueOf(Color.argb(alpha, red, green, blue))))

 fun tintDrawable(drawable: Drawable, colors: ColorStateList): Drawable {
        val wrappedDrawable = DrawableCompat.wrap(drawable)
        DrawableCompat.setTintList(wrappedDrawable, colors)
        return wrappedDrawable
    }
上一篇 下一篇

猜你喜欢

热点阅读