So imagine you have several Buttons on your layouts. The project is almost finished and there's a lot of dynamic stuff (programmatically setting images, listeners, statedrawables, etc. etc.).
Now, you're told that the buttons are kinda tricky to click so your first thought (at least mine) is "ok, I'll just make the bounding box bigger". To do this, I just need to give those Buttons more width and height so they will be easier to click.
My problem comes when I see that those Buttons are using background to store the image and so, whenever I make them bigger so does the image inside.
My question is, am I stuck with having to create a layout on top of it, assign the listener to this new, bigger layout, and then leaving the button as an image, or is there any easier way?
/¯¯¯¯¯¯¯¯¯¯¯¯\ <- outter layout
/¯¯¯¯¯¯¯¯\ | /¯¯¯¯¯¯¯¯\ |
| | | | | |
| BUTTON | ---> | | BUTTON | |
| | | | | |
\________/ | \________/ |
\____________/
Thanks
Nevermind, found the answer, I'll just leave it here in case anyone else is having this issue.
In our case we couldn't afford to edit the images, what I did is change the Button node to an ImageButton. Now, instead of using background we use src and, once the ImageButton is enlarged, a simple inside-padding is added so the image maintains the original size even though the button itself is actually bigger and, therefore, easier to click.
On a side note, if your previous background had alpha you might want to do this now:
android:background="@null"
Use this in your xml layout
android:background="@null"
This will help you to show you button as the image only
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With