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.
Asked
Active
Viewed 182 times
-6

Community
- 1
- 1

USAMA MALIK
- 65
- 1
- 7
1 Answers
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
-
its working fine for empty activity but not for pdfviewer...means if i tap on empty activity its hiding/showing the buttons but when i write same code for pdfviewer lib view its not working...can you tell me why its not working??? – USAMA MALIK Jan 22 '20 at 13:47
-
which pdfviewer you have used ? – Abhay Koradiya Jan 23 '20 at 04:58
-
check edited answer. – Abhay Koradiya Jan 23 '20 at 05:24
-
Thank you so much it's working like a charm – USAMA MALIK Jan 23 '20 at 08:25