ScrollView中的TouchImageView

Moh*_*ker 3 android scrollview touchimageview

我在ScrollView中有一个TouchImageView但是当我缩放imageview并尝试向上/向下滑动时,响应来自ScrollView.当我触摸TouchImageView时,有没有办法停止ScrollView

Dan*_* DC 7

您可以调用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;
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)