Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I increase a buttons onclick-area programmatically?

Tags:

android

button

Sometimes I have a button in my UI that it is so small that it is difficult to click. My solution so far has been to add a transparent border around the button in photoshop. Just increasing the padding on the button does not work, since this will also stretch the image. Since it is kind of a fuss to open photoshop each time I want to change the clickable surface, is there any way to do this programmatically? I have tried placing a framelayout behind the button and make it clickable, but then the button wont change appearance on touch as it should. Ofcourse I could also add a ontouchlistener on the framelayout which changes the buttons appearance, but then it quite some code if I have several of those buttons.

Cheers,

like image 787
pgsandstrom Avatar asked Jun 01 '10 11:06

pgsandstrom


1 Answers

Me personally, I'd use a TouchDelegate. This lets you deal with the touch target, and the visual view bounds as two different things. Very handy...

http://developer.android.com/reference/android/view/TouchDelegate.html

like image 108
GeorgeLawrence Avatar answered Sep 25 '22 23:09

GeorgeLawrence