Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to setColorFilter() in XML?

Tags:

java

android

xml

I'd like to know if a ColorFilter can be set in the XML of a View or if the only way is to use setColorFilter() in Java.

like image 321
Jecimi Avatar asked Oct 30 '12 11:10

Jecimi


3 Answers

There is; it's called tint. It's not available on View but is on ImageView and ImageButton.

If you want to use it with a selector this answer helped me a bunch.

like image 128
GDanger Avatar answered Sep 25 '22 02:09

GDanger


You can use:

android:tint="@color/white"
like image 37
Yogesh Rathi Avatar answered Sep 24 '22 02:09

Yogesh Rathi


According to the documentation http://developer.android.com/reference/android/graphics/ColorFilter.html there is no corresponding xml version for ColorFilter.

I also searched for attributes in documentation with the keys 'color' and 'filter' http://developer.android.com/reference/android/R.attr.html

like image 14
Martin Christmann Avatar answered Sep 25 '22 02:09

Martin Christmann