Unlike a regular Button , ImageButton or Button , which has an image background, is not disabled when disabled. You really have to use another image or process it in such a way that it looks gray.
If using another image in order, you can do this using <selector> (here associated with a regular Button , but this is among the same):
/drawable/my_selector.xml :
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_enabled="false" android:drawable="@drawable/button_gray" /> ***button_gray is a Drawable image*** <item android:state_pressed="true" android:drawable="@drawable/button_gray" /> <item android:drawable="@drawable/button_red" /> ***button_red is a Drawable image*** </selector>
Note that in the selector logic applies a sequential path, an element for each element. Here button_red used all the time, but when the button is disabled or pressed.
And if a problem with another image is a problem, other answers (e.g. @Tronman or @ southerton's) give you ways to programmatically process the image as if it is gray.
Shlublu Aug 29 2018-11-11T00: 00Z
source share