Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set color for imageview in Android

Tags:

android

I want set icon into ImageView and i downloaded icons from this site : FlatIcon
Now i want set color to this icons but when use setBackground just add color for background and not set to icons!
When use NavigationView i can set color to icons with this code : app:itemIconTint="@color/colorAccent".

How can i set color to icons into ImageView such as itemIconTint ? Thanks all <3

like image 585
Mohammad Nouri Avatar asked Jul 29 '16 07:07

Mohammad Nouri


1 Answers

If you are using an icon maybe this can be useful:

android:tint="@color/colorAccent" 

Otherwise you can try to modify the class:

ImageView imageViewIcon = (ImageView) listItem.findViewById(R.id.imageViewIcon); imageViewIcon.setColorFilter(getContext().getResources().getColor(R.color.blue)); 

More info in this thread: Is it possible to change material design icon color from xml in Android?

like image 75
El0din Avatar answered Sep 19 '22 20:09

El0din