I\'m actually trying to use colored icons in my app. I\'ve downloaded the official material design icon pack from here. Now all the icons in this pack are either white, grey
Many alternatives here already in this thread. Perhaps I can add one more for whoever finds it convenient :
You can also use the Drawable class, the code being as follows
Resources res = getResources();
Drawable drawable = res.getDrawable(R.drawable.ic_play_circle_filled);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, getResources().getColor(R.color.colorPrimary));
Although the above did the trick for me, but for my use case suggicient was to use android:tint
How to change material icon color in XML
<ImageButton
android:layout_width="YourValue"
android:layout_height="YourValue"
...
android:tint="YourColor" // this line do the magic
/>
I was looking for the same thing but to change it dynamically in the code. I hope this helps someone looking for the same thing.
Create an ImageView for the icon and use setColorFilter on that view.
ImageView imageViewIcon = (ImageView) listItem.findViewById(R.id.imageViewIcon);
imageViewIcon.setColorFilter(getContext().getResources().getColor(R.color.blue));