Hi, I want to implement in B4XPages (B4A) a gesture where, when the user swipes from the left edge to the right, the current page moves dynamically following the finger, revealing the previous page behind it. If the swipe passes a certain distance, the current page should close with an animation; otherwise, it should return to its original position — exactly like the swipe-back effect in Telegram chats.
You can achieve that using
1. sliding layouts (multiple b4a libraries are available each with its own merit)
2. use horizontal CLV with snap feature
3. viewpager (ahviewpager, as viewpager)
4. flowmenu
You can achieve that using
1. sliding layouts (multiple b4a libraries are available each with its own merit)
2. use horizontal CLV with snap feature
3. viewpager (ahviewpager, as viewpager)
4. flowmenu
Thanks for your answer. I tried the Gesture Detector library but its sample was not implemented based on B4xPages and also it only gave the swipe coordinates. I don't know how to use it to perform exactly like Telegram.
I tried to implement it like this but it doesn't work!
B4X:
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Private StartX As Float
Private IsSwiping As Boolean
Private Threshold As Int = 100dip
End Sub
Public Sub Initialize As Object
Return Me
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.Color=Colors.Blue
End Sub
Private Sub Root_Touch (Action As Int, X As Float, Y As Float)
Select Action
Case Root.TOUCH_ACTION_DOWN
StartX = X
IsSwiping = True
Case Root.TOUCH_ACTION_MOVE
If IsSwiping Then
Dim dx As Float = X - StartX
If dx > 0 Then
Root.Left = dx
End If
End If
Case Root.TOUCH_ACTION_UP
If IsSwiping Then
Dim dx As Float = X - StartX
If dx > Threshold Then
B4XPages.ClosePage(Me)
Else
Root.Left = 0
End If
IsSwiping = False
End If
End Select
End Sub
You need to elaborate on what happens and what did you expect because nobody knows what is "doesn't work"
Also you do not have to work with "root" if you were seeking a b4xpages compatible solution.
Refer to examples of "b4xpages transitions" and see how they create and animate pages and use same method in your logic.
You need to elaborate on what happens and what did you expect because nobody knows what is "doesn't work"
Also you do not have to work with "root" if you were seeking a b4xpages compatible solution.
Refer to examples of "b4xpages transitions" and see how they create and animate pages and use same method in your logic.