Kunal P.Bharati
Kunal P.Bharati

Reputation: 969

Android onTouchListener on LinearLayout

I have a linear layout with few child components in it. I have onTouchListener on the linearlayout. I want onTouch event to trigger when I touch child components of the linear layout too.

Upvotes: 4

Views: 4177

Answers (1)

Brian
Brian

Reputation: 16206

You should be able to implement the onInterceptTouchEvent method in a custom subclass of LinearLayout to achieve that effect. From the documentation:

public boolean onInterceptTouchEvent (MotionEvent ev)

Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.

Upvotes: 3

Related Questions