-6

In first image if you tap on screen than android gallery hide the all buttons as shown in second image while on again touch the screen you will find that all buttons re appear again. Note: On Zooming in-out,on Double tap or moving finger on image of galley don't effect the state it effect only when user tap on screen i want functionality like this. Please help me how can i implement such type of functionality to my Android app  please help me to solve it i had tried onTouchEvent etc with MotionEvent.ACTION_DOWN but it work every time when zoom in-out means every time when i tap on screen it workswhile ondouble tap or move finger on screen.

Community
  • 1
  • 1
USAMA MALIK
  • 65
  • 1
  • 7

1 Answers1

1

you can use 'GestureDetector' instead of ACTION_DOWN. Example,

 GestureDetector gestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            //------------------apply your logic here------------
            return super.onSingleTapUp(e);
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            return super.onSingleTapConfirmed(e);
        }
    });

and pass touch event to gesture.

@Override
public boolean onTouchEvent(MotionEvent event) {
    gestureDetector.onTouchEvent(event);
    return super.onTouchEvent(event);
}

Edited

After watching comment,

now issue is onTouchEvent not called if pdfviewer attached => This haapen because pdfviewer already consumed touch event.

So you need to use dispatchTouchEvent instead of that. check here

@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    gestureDetector.onTouchEvent(event);
    return super.dispatchTouchEvent(event);
}
Abhay Koradiya
  • 2,068
  • 2
  • 15
  • 40