我在ScrollView中有一个TouchImageView但是当我缩放imageview并尝试向上/向下滑动时,响应来自ScrollView。 当我触摸TouchImageView时,有没有办法停止ScrollView
答案 0 :(得分:6)
您可以调用requestDisallowInterceptTouchEvent(true);
来禁用scrollview的动作滚动
YourImageview.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
// Disallow ScrollView to intercept touch events.
scrollView.requestDisallowInterceptTouchEvent(true);
// Disable touch on transparent view
return false;
case MotionEvent.ACTION_UP:
// Allow ScrollView to intercept touch events.
scrollView.requestDisallowInterceptTouchEvent(false);
return true;
case MotionEvent.ACTION_MOVE:
scrollView.requestDisallowInterceptTouchEvent(true);
return false;
default:
return true;
}
}
});