views:

111

answers:

1

I have 2 ImageViews which have AnimationDrawable backgrounds to animate a box opening and closing when you click on it. The 2 images are slightly overlapping (the transparent area) so they can be closer together.

The problem this is causing is that I am unable to click on regions of the 1st image where the 2nd image (transparent area) is overlapping.

Is there a way to set a clickable region of an ImageView?

+1  A: 

I don't think that you can "define a clickable region on an ImageView" like you would do in HTML with a map. IMO the best you could do is draw a canvas on top of your ImageView with the same size, and give it an onClick method. Now, I don't know everything, so maybe I'm mistaken.

Sephy
Just a thought. Can this be resolved by adding touchable views on top using `addTouchables`?
Asahi
actually, I have never used this method and don't see exactly what it does, so maybe you're right. Have you tried it?
Sephy
haven't had a chance. could not find any examples either.
Asahi
That's what I thought too ;) I'll have a look at the source code of this method and come back later.
Sephy
Thanks - I used your original idea to create a clickable View overlaying the animating box. It was useful for me anyway as I'm animating the box + something popping out of the box so I added the box and the object as tags to the clickable view and onclick, I just got the 2 tagged objects out of the view and animated them.Still interested in the addTouchables solution so please let me know if it works.
Bruce Lee