Set Tint Color Of ImageView (Support Library)

April 22, 2018
Change color of icon using Tint Color

Tint

ImageViewCompat.setImageTintList(imageView, ContextCompat.getColorStateList(context, R.color.colorAccent))

Tips: Change tint color of ImageView will effectively change the drawable color which is black color originally.

You can create a black color Material Vector Icon by File -> New -> Vector Asset -> Clip Art, then assign the drawable to ImageView by setImageResource(R.drawable.ic_add_black_24dp).

Color Filter

Make the image darker by applying black overlay with 70% opacity

imageView.setColorFilter(Color.argb((255 * 0.3).toInt(), 0, 0, 0))

Clear color filter

imageView.clearColorFilter()
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.