我在 ScrollView 中有一个 TouchImageView,但是当我缩放 imageview 并尝试向上/向下滑动时,响应来自 ScrollView。当我触摸 TouchImageView 时,有什么方法可以停止 ScrollView
问问题
945 次
1 回答
7
您可以调用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;
}
}
});
于 2016-01-08T09:16:13.693 回答