ScrollView 里面的 TouchImageView
TouchImageView inside ScrollView
我在 ScrollView 中有一个 TouchImageView,但是当我缩放图像视图并尝试滑动 up/down 时,响应来自 ScrollView。
当我触摸 TouchImageView
时,有什么方法可以停止 ScrollView
您可以调用requestDisallowInterceptTouchEvent(true);
来禁用滚动视图的动作滚动
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;
}
}
});
我在 ScrollView 中有一个 TouchImageView,但是当我缩放图像视图并尝试滑动 up/down 时,响应来自 ScrollView。 当我触摸 TouchImageView
时,有什么方法可以停止 ScrollView您可以调用requestDisallowInterceptTouchEvent(true);
来禁用滚动视图的动作滚动
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;
}
}
});