0

After I have added multiple ImageViews to a LinearLayout and implementing the onTouch event, the touch is enabled only for the last added ImageView and all the previous ImageViews don'. What is the possible solution ?

I have tried the code from the android developer blog: http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html

Adham
  • 63,550
  • 98
  • 229
  • 344

2 Answers2

0

Multi-touch in that example is designed for multi-touching a single View, not for touching multiple views at the same time.

This might help: Android firing onTouch event for multiple ImageViews

The solution you might be looking for, if you want to give the effect of multi-touching ImageViews, is placing another view on top of those views which allows you to capture all the touch events and pass the appropriate action to the view below it.

In my experience it has been much easier to use a SurfaceView and render the images to the view myself but this wouldn't be appropriate if there are other behaviours of View which you want to take advantage of.

Community
  • 1
  • 1
Scott
  • 2,593
  • 1
  • 22
  • 23
  • 'if there are other behaviors of View which you want to take advantage of' .. what do you mean in these behaviors ? – Adham May 09 '12 at 05:27
  • Views obviously make it easier to create layouts and manage events whereas if you are rendering all the content yourself then you need to code this all yourself. For example, if you wanted to create a grid of images which might need cropping, backgrounds, etc. And you want to have multi-touch on the Images so you can re-arrange them then perhaps trying to overlay these images with a multi-touchable view would be the best route. Then you could easily use things like the Android Animation tools and such to make it look great without too much effort. – Scott May 14 '12 at 04:10
0

Android Launcher app supports moveable views using the touch interface. The Launcher object model includes objects like DragLayer, DragSource, DragController, and DropTarget.

Using this concepts there is a nice tutorial for Moving Views In Android.

Look at that, I think its what you needed.

user370305
  • 108,599
  • 23
  • 164
  • 151