Hey
I have an AbsoluteLayout
which has an OnTouchListener
. Inside this layout there is a much smaller LinearLayout
positioned dynamically. The OnTouchListener works as expected.
Now the problem comes when I add a LongClickListener
to my LinearLayout
. That disables my OnTouchListener
if the touch hits the LinearLayout
but it is still triggered, if the LinearLayout
was not hit by the touch.
My listeners:
// listener on parent (AbsoluteLayout)
setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.e("LOOOOGING");
mLinearLayout.getHitRect(mNoteRect);
mNoteRect.left += mX;
mNoteRect.top += mY;
mNoteRect.right = mNoteRect.left + mLinearLayout.getWidth();
mNoteRect.bottom = mNoteRect.top + mLinearLayout.getHeight();
if (mNoteRect.contains((int) event.getX(), (int) event.getY())) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
mStartX = (int) event.getX() - mNoteRect.left;
mStartY = (int) event.getY() - mNoteRect.top;
return true;
}
mX = (int) event.getX() - mStartX;
mY = (int) event.getY() - mStartY;
setPadding(mX, mY, 0, 0);
return true;
}
return false;
}
});
// listener on child (LinearLayout)
mLinearLayout.setOnLongClickListener(new OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
// do something...
return true;
}
});
How can I delegate the touch on the LinearLayout
where the OnLongClickListener
is registered, to the parent?