Shrikant Salunkhe
Shrikant Salunkhe

Reputation: 339

Android on touch events not detecting after scrolling

I am facing problem during detecting touch events. Its working fine without scrolling. But after scroll finished when I am removing finger not able to receive motion up event.I am using following code.

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;
            }
        });

Upvotes: 0

Views: 761

Answers (1)

Android
Android

Reputation: 9033

your_control.setMovementMethod(new ScrollingMovementMethod());

and

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

Upvotes: 1

Related Questions