Multiple Views OnTouch Events

后端 未结 3 1343
迷失自我
迷失自我 2021-01-02 05:56

We are developing an application where we need to capture MotionEvents from multiple views simultaneously. When we try to do so, Android only dispatches events to the first

相关标签:
3条回答
  • 2021-01-02 06:30

    Touch event is first catched by the view currently in focus. If you touched 1 view and have "consumed" event and are working with it, any other events will be dispatched to this view, no matter where you click.

    If you return false from your touchListener (thus saying that event is not consumed) it will be delegated down to other views, but on another separate click new event will be dispatched to other view.

    http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-3-understanding-touch-events/1775

    http://developer.android.com/guide/topics/ui/ui-events.html

    0 讨论(0)
  • 2021-01-02 06:32

    While this should work automatically with Android SDK 11+, it wasn't working for my app. I was trying to capture touches in a main view, plus some views that were subviews of the main view; in that case, touches were only captured by the view "level" that received the first touch. I reorganized my view structure so that all the views were siblings and now they are capturing events as expected.

    0 讨论(0)
  • 2021-01-02 06:41

    At least Android 3.0 adds support for splitting touch events between multiple Views.

    Split touch events is enabled by default when AndroidManifest <uses-sdk> defines either android:minSdkVersion="11" or android:targetSdkVersion="11". For explanation See android:splitMotionEvents and android:windowEnableSplitTouch

    0 讨论(0)
提交回复
热议问题