3

Here is the scenario; I have 3 PNG photos i wanna use as background of buttons or ImageViews and they are overlapping in a relative layout. kinda like this:

RelativeLayout

so the red button will be the biggest and go under all of them, then i will add green button on top of red and then yellow button on top of green. so that's how it looks like. each button has a PNG background as i said at the beginning.

Problem is I cant make the only visible area of each Button/ImageView clickable! Android kinda considers each at rectangle button/ImageView. Any solution for this?

4

1 回答 1

1

在你的onTouchListener你应该检查事件MotionEvent)是否在背景的透明区域中。

onTouchListener如果事件在(参数的)透明区域中,您可以为每个视图/按钮单独创建一个并返回 false,View或者您可以为所有按钮创建一个侦听器,忽略View参数并检查所有三个视图以确定事件发生在哪一个事件中。

于 2013-09-19T09:19:31.223 回答