I'd like to use a selector to grey out an icon when it is not enabled. It seems that something like this should work (with a white background):
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" >
android:alpha="0.5"
</item>
<item android:state_enabled="true" >
android:alpha="1"
</item>
</selector>
But it results in a java.lang.NumberFormatException during run time. I also tried "0.5f". Same error.
This is similar to Is there a way to set drawable's Alpha using XML? but I'm specifically asking about the NumberFormatException. Incidentally, I also tried using integer values between 0 and 255. I get the same error.