Android Question Statelist drawable pressed state

Emme Developer

Well-Known Member
Licensed User
Longtime User
Hi, i make a statelist drawable in a button, but i really don't understand why pressed state doesn't change.
Can anyone helps me? Thanks

B4X:
Sub MakeButtonDrawable(color As Int,size As Int) As StateListDrawable
    Dim cdEnabled As ColorDrawable
    cdEnabled.Initialize2(0x00000000,4dip,size,color)
   
    Dim cdPressed As ColorDrawable
    cdPressed.Initialize2(0x00000000,4dip,size+2dip,color)

    Dim gdwDisabled As ColorDrawable
    gdwDisabled.Initialize(0x00000000,0)
    ' Define a StateListDrawable
    Dim stdGradient As StateListDrawable
    stdGradient.Initialize
    stdGradient.AddState(stdGradient.State_Enabled,cdEnabled)
    stdGradient.AddState(stdGradient.State_Pressed, cdPressed)
    stdGradient.AddState(stdGradient.State_Disabled, gdwDisabled)
    Return stdGradient
End Sub

bn.Background = Utils.MakeButtonDrawable(Colors.White,1dip)
 
Top