3

I'm implementing an app that uses part of the screen as a touchpad for the user to manipulate a mechanical device. I want to limit the touchpad behavior to only that View.

But if the user puts his finger down inside that View and moves it outside the View in my onTouch() Handler I continue to get ACTION_MOVE events when the user is dragging outside the View.

And the View ID passed-in to onTouch() is still that of the original View even though the events are coming from outside that View's bounds!

Why does it do this and how can I constrain events to only within the bounds of that one View?

Thanks in advance.

prolink007
  • 33,872
  • 24
  • 117
  • 185
user316117
  • 7,971
  • 20
  • 83
  • 158

2 Answers2

1

I found an answer eleswhere on SO -

Android: Detect if user touches and drags out of button region?

I had to move the "return false;" statement up inside the curly braces where "// User moved outside bounds", but otherwise I was able to use it intact. So, thanks to Entreco.

Community
  • 1
  • 1
user316117
  • 7,971
  • 20
  • 83
  • 158
0

Try with Fragments.

Each fragment has own UI event handler. I hope that's enough for you :)

klimat
  • 24,711
  • 7
  • 63
  • 70
  • Reading the documentation on Fragments, per your link, it looks like that won't address the problem, because each fragment gets its own View hierarchy and since the events are still coming from the original View even when outside that View's bounds, they'll still get processed in that same fragment even when outside that View's bounds. – user316117 Aug 17 '12 at 15:35