Android Question states.State_Hovered

Martin Domian

Member
Licensed User
Longtime User
Hi.

I want the buttons to behave the same as DefaultDrawable, but with my colors:

Then the hover effect disappears. I move the mouse over it and nothing happens.
State_Hovered is supported by Android, but is not available in B4A. But since it works with the default setting, there must be an easy way.

here is the way, which is not working.

Thanks for any ideas

Martin


Sub CreateStateDrawable(normalColor As Int, pressedColor As Int, focusedColor As Int) As StateListDrawable
Dim states As StateListDrawable
states.Initialize

' Gedrückt
Dim pressedDrawable As GradientDrawable
pressedDrawable.Initialize("TR_BL", Array As Int(pressedColor, pressedColor))
states.AddState(states.State_Pressed, pressedDrawable)

' Fokus
Dim focusedDrawable As GradientDrawable
focusedDrawable.Initialize("TR_BL", Array As Int(focusedColor, focusedColor))
states.AddState(states.State_Focused, focusedDrawable)

' Normal
Dim normalDrawable As GradientDrawable
normalDrawable.Initialize("TR_BL", Array As Int(normalColor, normalColor))
states.AddState(states.State_Enabled, normalDrawable)

Return states
End Sub
 

drgottjr

Expert
Licensed User
Longtime User
there is no hovered state for a button. there is one for a view (which is what you were probably referring to).
to get that to work with a button, you need a listener. but not an ontouch listener. a genericmotion listener is needed.
that's a little trickier than a standard listener. i'm looking into that. if someone else beats me to it, no problem.
otherwise, i'll post as soon as i can get it running.
 
Upvote 0
Top