[Solved] how can i get functionality like show/hide buttons in Android gallery on screen tap [closed]


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

4

solved how can i get functionality like show/hide buttons in Android gallery on screen tap [closed]