2 Replies - 902 Views - Last Post: 16 July 2018 - 01:41 PM

#1 NameWasTaken   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-July 18

Android - Passing click onto child

Posted 15 July 2018 - 03:28 PM

Hello,

So im in this situation that I've implmented an overlayservice (image) which floats above everything inside of the app.

The thing is that even though the overlay overlaps an underlying object for instance a button, and if there is a click it should pass the click onto the child (button).

I have an issue doing this, I just can't seem to pass the click.

Provided code for the service;

overlayView.setOnTouchListener(new View.OnTouchListener() {
        private WindowManager.LayoutParams paramsF = params;
        private int initialX;
        private int initialY;
        private float initialTouchX;
        private float initialTouchY;

        @Override public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:

                // Get current time in nano seconds.

                initialX = paramsF.x;
                initialY = paramsF.y;
                initialTouchX = event.getRawX();
                initialTouchY = event.getRawY();
                break;
            case MotionEvent.ACTION_UP:
                break;
            case MotionEvent.ACTION_MOVE:
                paramsF.x = initialX + (int) (event.getRawX() - initialTouchX);
                paramsF.y = initialY + (int) (event.getRawY() - initialTouchY);
                windowManager.updateViewLayout(overlayView, paramsF);
                break;
            }
            return false;
        }



Any idea of how to fix this?

Is This A Good Question/Topic? 0
  • +

Replies To: Android - Passing click onto child

#2 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2880
  • View blog
  • Posts: 11,262
  • Joined: 03-December 12

Re: Android - Passing click onto child

Posted 16 July 2018 - 06:56 AM

Why do you have an overlay over the app? Just seems, odd.
Was This Post Helpful? 0
  • +
  • -

#3 NameWasTaken   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-July 18

Re: Android - Passing click onto child

Posted 16 July 2018 - 01:41 PM

It's actually not odd at all. Its an overlay of a mouse pointer(cursor).
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1