2

So i have a LinearLayout that consists of several items that have a ripple effect which is triggered on touch. This LinearLayout is designed to collapse downwards when you swipe over it or touch any of the items. Whenever the item is touched there is a delay before the layout starts collapsing in order to give the ripple effect of this item time to finish the animation. Also LinearLayout has a gesture listener and when it recognizes the swipe down the collapsing animation starts. Unfortunately whenever i start swiping the first touch event of the swiping motion is also getting recognized as item touch and layout collapsing animation and ripple animation run simultaneously and it looks ugly. Any ideas on on how i can avoid ripple effect from being triggered in this case?

My guess is that i have to stop propagating touch events from linear layout to the childs while swiping but i can't figure out the way to do it.

Here is an image to illustrate my problem.enter image description here

Arnis Shaykh
  • 544
  • 5
  • 21
  • Post your onTouchEvent function. Most likely what we need to do is delay any animation until the TOUCH_UP event. – Gabe Sechan Jan 06 '17 at 19:07
  • My items do not have onTouchEvent function (ripple effect works automatically). – Arnis Shaykh Jan 06 '17 at 19:13
  • Something is putting on an on touch event to detect the swipe – Gabe Sechan Jan 06 '17 at 19:15
  • But how do you tell a difference between just the touch and touch that continues with a swipe? – Arnis Shaykh Jan 06 '17 at 19:21
  • You look at a series of touch events, passing it through a state machine. Basically you look for a down, followed by moves, followed by an up. You can't tell its a swipe until either a big enough move or an up (depending on the implementation). – Gabe Sechan Jan 06 '17 at 19:24
  • I tried that and a simple touch is similar. Down followed by several move events and the up. I guess that happens because you can not hold your finger exactly on one pixel. So simple touch also triggers up to 20 "move" events. – Arnis Shaykh Jan 06 '17 at 19:28
  • 1
    Yes, it does. You have to look at the distance it moves from the initial touch position (sent in the touch down) and make sure it moves far enough (and far enough needs to scale with pixel density, of course). – Gabe Sechan Jan 06 '17 at 19:30
  • Seems like a solution, i'll try it. Thanks – Arnis Shaykh Jan 06 '17 at 19:36

0 Answers0