滚动后未检测到Android触摸事件

时间:2014-03-26 07:12:17

标签: android android-layout android-view android-debug

我在检测触摸事件时遇到问题。它的工作正常,无需滚动。但滚动完成后,我正在移除手指无法接收动作事件。我正在使用以下代码。

linearMain.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {

                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    // Do Something
                    Log.d("Touch", "Touch down");

                    // Now Set your animation
                    slidingDrawerMos.startAnimation(slideOutAnimation);
                     slidingDrawerReviews.startAnimation(slideOutAnimation);

                    slidingDrawerMos.setVisibility(View.GONE);
                    slidingDrawerReviews.setVisibility(View.GONE);

                    break;

                case MotionEvent.ACTION_MOVE:
                    // Do Something
                    Log.d("Touch", "Touch move");
                    break;

                case MotionEvent.ACTION_UP:
                    // Do Something
                    Log.d("Touch", "Touch up");
                    slidingDrawerMos.setVisibility(View.VISIBLE);
                    slidingDrawerReviews.setVisibility(View.VISIBLE);

                    // Now Set your animation
                    slidingDrawerMos.startAnimation(slideInAnimation);
                    slidingDrawerReviews.startAnimation(slideInAnimation);
                    break;

                case MotionEvent.ACTION_CANCEL:
                    Log.d("Touch", "Touch cancel");
                    break;
                default:
                    break;
                }

                return true;
            }
        });

1 个答案:

答案 0 :(得分:1)

your_control.setMovementMethod(new ScrollingMovementMethod());

 findViewById(R.id.your_control).getParent()
                            .requestDisallowInterceptTouchEvent(false);