Android examples for Graphics:Drawable Tint
tint Drawable
import android.content.Context; import android.content.res.ColorStateList; import android.graphics.drawable.Drawable; import android.support.v4.graphics.drawable.DrawableCompat; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; import java.lang.reflect.Field; public class Main{ public static Drawable tintDrawable(Drawable drawable, ColorStateList colors) {//from ww w .j a va2 s . co m final Drawable wrappedDrawable = DrawableCompat.wrap(drawable); DrawableCompat.setTintList(wrappedDrawable, colors); return wrappedDrawable; } public static void tintDrawable(Context context, ImageView imageView, int colorResID) { Drawable originalDrawable = imageView.getDrawable(); if (originalDrawable == null) { return; } imageView.setImageDrawable(tintDrawable( originalDrawable.mutate(), ColorStateList.valueOf(context.getResources().getColor( colorResID)))); } }