proper highlighting of pressed image buttons?

Dave O

Well-Known Member
Licensed User
Longtime User
I'm using some image buttons in my app's titlebar, using standard Android icons (Holo Light) in a StateListDrawable.

The buttons are 48x48, and I'm using the MDPI icon (32x32) centered, so I get the standard 8dip whitespace around it.

The Enabled state is OK, but I'm not sure how to handle the Pressed state.

From looking at the Gmail and Calendar apps (as good examples), it looks like the pressed state is the same graphic with a blue "highlight" background.

So ideally, I would like to be able to define the Pressed state as "same icon, but different background colour". But I'm not sure if that's possible when using a StateList. Do I need to create my own blue-background icon manually?

And if so, does that mean I have to create 48x48 images that include the whitespace? (The highlighting should go beyond the actual 32x32 icon in the middle of the button.)

Hoping this makes some sense, and really hoping there's a proper, elegant way to do this. It just seems harder than it should be to get a fairly standard behaving image button. (This, admittedly, from a B4A beginner. ;^)
 

klaus

Expert
Licensed User
Longtime User
If the images are Android standard images I think that you should also find the pressed state images at the same source.
And then define a StatListDrawable and set it to the button background.
If you dont get the pressed image you must define your own.
StateListDrawables are treate in the User's Guide.

Best regards.
 
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
I'm using the "Action Bar Icon Pack" from the official Android Design Guide (from Google), but there is only the Enabled state - no Pressed or Disabled states.

Which means some tedious mucking about in a paint program. For bog-standard icons. Sigh...

BTW, does B4A support image+text buttons, using the left-drawable attribute? I haven't been able to figure this one out either.

Thanks!
 
Upvote 0
Top