Android Question sliding panels with 2-finger swipe?

Dave O

Well-Known Member
Licensed User
Longtime User
Hi all,

I'm looking for the best (easiest?) way to add 2-finger swipes to my sketching app so the user can navigate between pages of sketches.

The "sliding panels" libs and classes that I've seen so far do their sliding based on 1-finger swipes.

In my case, 1 finger means "I'm drawing on the canvas", so I'd like to trigger the slide on a 2-finger swipe.

I'm hoping I can combine one of the sliding-panel libs or classes with a gesture library (e.g. Gesture Detector) to get this result.

On a related note, there could be dozens of panels involved. Is there a way to dynamically just load 3 panels at once (the current one, plus the adjacent ones), to conserve memory?

Thanks!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This (old) example implements a sliding navigation: https://www.b4x.com/android/forum/threads/8233/#content

You can change the implementation to track two fingers only with the Gestures library: https://www.b4x.com/android/forum/threads/10419/#content

There might be a simpler solution with one of the other gestures related libraries.

About the memory, panels by themselves do not consume any significant memory. You should make sure that you are not creating a new canvas for each panel or something like that.
 
Upvote 0

Dave O

Well-Known Member
Licensed User
Longtime User
Hmm, that's what I figured - use one of the existing sliding-panel solutions and try combining that with a gesture library. Will try that and report back.

For the panels, each panel has a canvas for drawing a sketch. Currently I just load one at a time (because they can only see/edit one at a time).

However, for sliding, I assume I'll need to load the adjacent panels too, so they can be seen as they slide in.

What I'm hoping is that I can just keep doing that (load the current canvas and the adjacent ones), without having to load all of them (could be dozens) at once. I'll check the various sliding-panels solutions and see if they can do that kind of just-in-time loading.

Thanks!
 
Upvote 0
Top