I don't think you can change the existing one but you can replace it.
B4X:
Dim gd1 As GradientDrawable
Dim gd2 As GradientDrawable
Dim cols(2) As Int
cols(0) = Colors.Cyan
cols(1) = Colors.Red
gd1.Initialize("TL_BR",cols)
gd2.Initialize("TR_BL",cols)
Dim states(1) As Int
Dim sd As StateListDrawable
sd.Initialize
Dim states(2) As Int
states(0) = sd.state_enabled
states(1) = -sd.state_pressed
sd.addState(states, gd1)
Dim states(1) As Int
states(0) = sd.state_pressed
sd.addState(states, gd2)
Button1.Background = sd
The order the states are added is important because the Android state matching algorithm is a simple linear search. Unfortunately I can't get a state to show for the unpressed condition so the button is black until pressed. Most likely I'm not understanding something or the StateListDrawable is missing a state constant. Erel did say it wasn't finished. I've tried various integer constants to define the unpressed state but can't hit on the right one.
EDIT:- I've got it work and changed the code above but I have to admit I don't understand why it needs the enabled and unpressed combination to display the unpressed state instead of just the unpressed (-ve) state when it doesn't appear to need it for the pressed state.
It's not exaclty what I wanted to do but you showed me the way how to do it !
I wanted to change the bitmaps to simulate a ToggleButton, when pressing the bitmaps change and remain when unpressed and on the next press.
Attached a small test program for others who might be interested in.
Playing with 3 buttons Bitmap-, Gradient-, Color Drawable