Android Question sliding panels with 2-finger swipe?

Discussion in 'Android Questions' started by Dave O, Feb 28, 2015.

  1. Dave O

    Dave O Active Member Licensed 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?

  2. Erel

    Erel Administrator Staff Member Licensed User

    This (old) example implements a sliding navigation:

    You can change the implementation to track two fingers only with the Gestures library:

    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.
  3. Dave O

    Dave O Active Member Licensed 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.

  4. Erel

    Erel Administrator Staff Member Licensed User

    You should create 3 mutable bitmaps (and canvases) and reuse them.

    You can show the mutable bitmaps with ImageView.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice