Is it possible to change material design icon color from xml in Android?

前端 未结 9 1066
囚心锁ツ
囚心锁ツ 2020-12-05 06:39

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

9条回答
  •  Happy的楠姐
    2020-12-05 07:39

    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));
    

提交回复
热议问题