Reputation: 1397
Edit: I am using LibGDX framework.
There is an Image
Actor, which is:
Stage
.OnClickListener
, e.g.:image.addListener(new OnClickListener() { ... });
This Image's touchable area is fixed on the image's width and height.
I want to increase the touchable area by N pixels.
How can I achieve this?
Here's an illustration: (red rectangle = touchable/clickable area)
Upvotes: 2
Views: 341
Reputation: 2220
The way I would approach it, is to have a custom image view, with the actual Image View inside a RelativeLayout. The relative layout has padding and/or margin set, so that it is bigger than the imageView. then, when you set the onClicklistener, set it on the relative layout as well as the image layout (in your custom class)
Upvotes: 1
Reputation: 19776
Image
already supports this out of the box. The actor can be bigger than the drawn image itself. You can supply a Scaling
strategy for the drawn picture and in case you use Scaling.none
, the drawn picture will be independent of the actor's size.
image.setScaling(Scaling.none)
int N = 30;
image.setSize(image.getImageWidth() + N, image.getImageHeight() + N);
Upvotes: 1