我有一个像这样的布局:
RelativeLayout_Parent
-> RelativeLayout_Child
两个视图都有触摸事件。但是当我触摸 RelativeLayout_Child
时,父视图的触摸事件也被触发了。
如何避免在子视图触摸时引起父视图触摸?
我有一个像这样的布局:
RelativeLayout_Parent
-> RelativeLayout_Child
两个视图都有触摸事件。但是当我触摸 RelativeLayout_Child
时,父视图的触摸事件也被触发了。
如何避免在子视图触摸时引起父视图触摸?
child_view.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// this will make sure event is not propagated to others, nesting same view area
return true;
}
});
focusable="false"
和enable="false"
。 - Piyush