0

I'm trying to create a ImageButton that changes it's icon based on wether it's enabled or not. I've created the following file:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/icn_increase_inactive" />
    <item android:state_enabled="true" android:drawable="@drawable/icn_increase_active" />
</selector>

When toggling the state between enabled and disabled nothing changes. Also i tried to create my own ImageButton that extends ImageButton and try and manually switch the state, but within the ImageButton it's loading the drawable as a BitmapDrawable and not as a StateListDrawable. When loading outside of the image button it works as a StateListDrawable though. Any ideas?

martin treurnicht
  • 1,223
  • 1
  • 10
  • 17

1 Answers1

1

I can't believe this, after struggling with this for so long. All i needed to do is swap the items around. The the default state should always be at the bottom it seems. Hope this saves someone else a lot of time

martin treurnicht
  • 1,223
  • 1
  • 10
  • 17