I have a RelativeLayout
with a thin red frame background and a (mostly transparent) ImageView
as a child. Their sizes are equal:
On screen it looks as follows:
When user presses this compound object, I want to change frame's color to green:
I set RelativeLayout
's background to a StateListDrawable
that switches red to green. It works fine until I add a child ImageView
(representing blue letter "A") to the RelativeLayout
. This ImageView intercepts input touches and therefeore blocks input. I tried to call
imageView.setEnabled(false);
imageView.setFocusable(false);
relativeLayout.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
but nothing helped.
How do I make an ImageView "transparent" to input events?
Set an OnTouchListener to the ImageView that returns false in any case. This way the touch event wont be consumed and gets passed on to the next Listener.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.