Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageView src with drawable selector ignores enabled state

When using a state selector as the src for an ImageView, enabled="false" is being ignored.

i.e. this doesn't work properly:

<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:enabled="false"
        android:src="@drawable/state_drawable" >

P.S. : I have an ugly workaround, I'll post it as an answer shortly, if you have something better or an explanation for this behavior, please let me know.

like image 631
marmor Avatar asked May 03 '12 10:05

marmor


Video Answer


2 Answers

Try to add the property android:clickable="true"

like image 61
Changwei Yao Avatar answered Sep 30 '22 09:09

Changwei Yao


Possible workaround: use a TextView with a compound drawable:

<TextView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:drawableLeft="@drawable/state_drawable"
     android:enabled="false" />

This seems to work, and pull the right drawable from state_drawable, but not very intuitive.

like image 42
marmor Avatar answered Sep 30 '22 10:09

marmor