I have a small Android ImageButton on a screen representing an icon. The problem is that it is difficult to touch, and activate. I don’t want to increase the size of the image itself but I would like to expand the clickable region and make it larger, so if the user is close enough to the image it will activate the onClick event. How can this be done without implementing onTouch events for the surrounding screen area?
Share
You could wrap your
ImageButtonin anotherViewGroupand set padding on theViewGroup. Then you would listen for clicks on theViewGroup. Here’s an example:You would then listen for clicks on
R.id.button_layout, and yourImageButtonshould receive all the same states (pressed, clicked, etc.) as the parent layout.