'globals
Private minDistance As Int = 30
Private x1,x2,y1,y2 As Float
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
Select Action
Case Activity.ACTION_DOWN
x1 = x
y1 = y
Case Activity.ACTION_UP
x2 = x
y2 = y
Private deltaX As Float = x2 - x1
Private deltaY As Float = y2 - y1
If Abs(deltaX) > minDistance And deltaY < minDistance Then 'minDistance set in Globals
If x2 > x1 Then 'if left to right ..
Log("Right Swipe ...")
Else 'if right to left ..
Panel1.SetLayoutAnimated(400, Panel1.Left, Panel1.Top, 20dip, Panel1.Height)
Log("Left Swipe ...")
End If
End If
End Select
End Sub
I've not tried, but this logs only if i swiped left or right, doesn't move the panel , right?something like this .. ? I would swipe to left to unlock.
B4X:'globals Private minDistance As Int = 30 Private x1,x2,y1,y2 As Float Sub Panel1_Touch (Action As Int, X As Float, Y As Float) Select Action Case Activity.ACTION_DOWN x1 = x y1 = y Case Activity.ACTION_UP x2 = x y2 = y Private deltaX As Float = x2 - x1 Private deltaY As Float = y2 - y1 If Abs(deltaX) > minDistance And deltaY < minDistance Then 'minDistance set in Globals If x2 > x1 Then 'if left to right .. Log("Right Swipe ...") Else 'if right to left .. Log("Left Swipe ...") End If End If End Select End Sub