Android Question Interacting and moving a panel

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, my question is...
It's possible to interact with a panel in order to move it like the old "swipe to unlock" of iPhone?

I have a panel and i would like to swipe it to the the right (and after that do something in my application)
 

mangojack

Expert
Licensed User
Longtime User
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 ..
                    Panel1.SetLayoutAnimated(400, Panel1.Left, Panel1.Top, 20dip, Panel1.Height)
                    Log("Left Swipe ...")
                End If
            End If
    End Select
 
End Sub
 
Last edited:
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
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

I've not tried, but this logs only if i swiped left or right, doesn't move the panel , right?
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Have edited the above post ... to move the panel as well .

This was intended as a hint how to use a panel swipe.

Search SetLatoutAnimated, SetLayout, Invisible, Not Invisible, or whatever you are going to do with your panel once the user has swiped it ...
Or was I to guess that and code it for you.
 
Upvote 0
Top