Little search showed that ACTION_CANCEL is the right value to get from the system, but the (X,Y) values on this event are not proportional to the gesture I made :S Y values are way bigger than expected I did expand the HitRect size, but it's still too big
On Friday, August 23, 2013 10:24:03 PM UTC+3, OronS wrote: > > Hi :) > Thanks for your post > > I'm trying to implement specific gesture between images...no drag & drop > The images are inside *GestureOverlayView (because of prediction = > gestureLibrary.recognize()...I don't know how to recognize a gestures which > have curls or shapes)*, and I thought the parent intercepts touch event > automatically (by automatically I mean set the OnTouch listener to the > parent). > Don't you think inheritance is wrongly used in this case?? > > Anyway..I used *gestureOverlayView.setOnTouchListener* to intercept touch > events on children, and *gestureOverlayView.addOnGesturePerformedListener*to > check whether the gesture was recognized, and user's finger passed > through both images. > > The problem now is that in *gestureOverlayView.setOnTouchListener,*instead of > ACTION_UP, I get ACTION_CANCEL :S > > I don't know if it should be like that > > On Friday, August 23, 2013 6:17:23 PM UTC+3, Nobu Games wrote: >> >> Is it just gestures or are you trying to implement drag and >> drop<http://developer.android.com/guide/topics/ui/drag-drop.html>(because it >> sounds like that). Either way you could just intercept motion >> events in the parent view group that contains your images and let it handle >> your gesture recognition. >> >> So let's say you create a derivative class "L" of your layout that >> contains the image views. >> >> You could override >> dispatchTouchEvent(MotionEvent)<http://developer.android.com/reference/android/view/ViewGroup.html#dispatchTouchEvent%28android.view.MotionEvent%29>of >> L and check for the following motion event states: >> >> *1. Gesture started (ACTION_DOWN)* >> Iterate your list of ImageView children of L and see if the touch event >> point is in one of them. If yes, your gesture starts. >> >> The View class has the method getGlobalVisibleRect(Rect, >> Point)<http://developer.android.com/reference/android/view/View.html#getGlobalVisibleRect(android.graphics.Rect,%20android.graphics.Point)>which >> can be used for checking if your touch event coordinate hits one of >> your image views. It would roughly look like the following (not tested >> since I'm not sure if these methods return locations in screen or window >> coordinate system, you may need to debug it): >> >> *Rect* r = new *Rect*();* *// should be class member you can reuse >>> float x = motionEvent.getRawX(); >>> float y = motionEvent.getRawY(); >>> >>> *for*(*ImageView* iv : imageViews) { >>> iv.getGlobalVisibleRect(r); >>> >>> *if*(r.contains(x, y)) { >>> // Touch event is inside image view >>> } >>> } >>> >> >> *2. Gesture ongoing (ACTION_MOVE)* >> If you visualize your gesture by drawing some trail or moving around the >> first touched image view then this is the right point to do so. Here you >> can update your view(s). >> >> *3. Gesture finished (ACTION_UP)* >> Here you need to iterate your ImageView children again in order to see if >> the finger has been lifted over another image view. In that case your >> gesture was successful. >> >> *4. Gesture canceled (ACTION_CANCEL)* >> Whatever your gesture is doing should be canceled here. >> >> >> On Friday, August 23, 2013 1:21:59 AM UTC-5, OronS wrote: >>> >>> Hi there [image: :)] >>> >>> I have two ImageViews in my app. >>> I've added a gesture detector (GestureOverlayView), and added gestures >>> to the app by using android's sample, which record gestures and save them >>> to a file, and I then load this file. >>> >>> My Goal is to limit the gestures area.. I want them to start from one >>> ImageView, and end on the other. >>> I didn't find anything on google!! : / >>> >>> I've added OnTouch listener to both images, but I don't know how to >>> detect a gesture coming from the outside of a View. >>> >>> I can detect a gesture starts from one Image ("Down" event), but when my >>> finger goes over the second and then go up, the event triggered is "Cancel" >>> on the first image >>> >>> Please Help >>> >>> Thanks, >>> Oron >>> >> -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

