I have a custom view which draws its brackground as an hexagon. I also made a custom RecyclerView layout manager to dispose my custom view in a honeycomb fashion:
I don't want the item to be clicked (neither show a ripple) when the click is in the bounds of the view, but outside the hexagonal background.
Simple: override dispatchTouchEvent()
on the view, if the clicks occurs outside of the background ignore the event.
Problem is, in fact, this click might be in the pink zone, which is received by view B, but should be handled by view A
Can I do something about this ?
I don't know what you mean by "onDispatchTouchListener", which I've never heard of, but I think the easiest way to solve this is to override onTouchEvent
and return false when outside your hexagon.
override fun onTouchEvent(event: MotionEvent): Boolean = when {
isInHexagon(event.x, event.y) -> super.onTouchEvent(event)
else -> false
}