Skip to content Skip to sidebar Skip to footer

Disable Button With Custom Background Android

When I have an android button and set it as disabled then the button seems as 'transparent'. I have a button with custom background for the pressed and focused state. I want to dis

Solution 1:

you should create you custom selector like this:

<selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:state_enabled="false"android:drawable="@drawable/btn_red" /><itemandroid:state_pressed="true"android:state_enabled="true"android:drawable="@drawable/btn_orange" /><itemandroid:state_focused="true"android:state_enabled="true"android:drawable="@drawable/btn_orange" /><itemandroid:state_enabled="true"android:drawable="@drawable/btn_black" /></selector>

Solution 2:

Maybe you could use android:state_enabled and set that to appropriate transparent drawable in your selector for this button?

Post a Comment for "Disable Button With Custom Background Android"