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

前端 未结 9 1080
囚心锁ツ
囚心锁ツ 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条回答
  •  盖世英雄少女心
    2020-12-05 07:25

    You can use the TintImageView within the appcompat support library and then tinting/coloring the imageview is by simply calling the android:backgroundTint to tint the imageview into one color.


    Xml

    
    

    or

    
    

    Programatically

    ImageView yourImageView = findViewById(...) yourImageView.setColorFilter(Context.getColor(your_color_here))


    So the above xml will tint the imageView to color green, means that it will colorize each pixel of the imageview that are visible to green.

提交回复
热议问题