Instead of setOnClickListener use setOnTouchListener
This code will work as an onclick event
YourLinearLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
boolean returnValue = true;
if(event.getAction()==MotionEvent.ACTION_UP){
returnValue = false;
}
return returnValue;
}
});
And then add this to your LinearLayout class to catch child touch events
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return true;
}
source
share