How to set color filter to drawable programmatically in android Example
Setting Color Filter to your Drawable image programmatically. I’m sure you also got this question when you need the same image but in the different color. The First solution is to generate the new image and use it. And ther option is to add color filter to an image and use it. In the tutorial I explained how to set the custom color to Drawable programmatically.
Here’s the very short code to set Color Filter to Drawable.
ImageView lineColorCode = (ImageView)convertView.findViewById(R.id.line_color_code); int color = Color.parseColor("#787878"); //The color u want to change lineColorCode.setColorFilter(color); // set color filterter
Hope, you like our short and simple solution for set color filter to drawable.