Android Set ImageView Tint Programatically

June 21, 2019

By code

var color = ContextCompat.getColor(context, android.R.color.darker_gray)
ImageViewCompat.setImageTintList(likeButton, ImageView.valueOf(color))

Via XML

<ImageButton
    android:id="@+id/imageView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:tint="@android:color/darker_gray"
    app:srcCompat="@drawable/ic_add_block_24dp"
    />
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.