Question Detail

I can set tint through XML but I  am not able to set it programmatically so please tell me how can I set tint Color programmatically.


Thread Reply

Anonymous

- 1 years ago

try this:

imageView.setColorFilter(ContextCompat.getColor(context, R.color.COLOR_YOUR_COLOR), android.graphics.PorterDuff.Mode.MULTIPLY);

its for me.

Correct Answer

Hemant Sharma

- 1 years ago

Programmatically Try : 

imageView.setColorFilter(Color.argb(245, 57, 57,5));


and

Try this in your XML file :

<ImageView
            android:id="@+id/image_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_user"
            android:tint="#ff0000"
            />