Nativ
Nativ

Reputation: 3150

Android stacked image gallery

I'm trying to create a stacked image gallery, this is a gallery on which all the pictures are overlaying each other in a stack(or pile), for example: a card pile, and the user would be able to see and touch just the upper image and to flip/throw it out of the screen(with translate animation). After throwing the first picture the user will see the second picture that was hidden underneath the first one and so on.

I didn't find a similar gallery in other apps except to "weheartpics" (for Iphone off course)

The line of solution that I'm following now is to create a FrameLayout, adding some overlaying pictures on it, to delete the upper picture when the user touch it(instead of throw it out of screen).

Upvotes: 0

Views: 690

Answers (4)

Nativ
Nativ

Reputation: 3150

Ok, the solution for that problem was to use frameLayout and to add to it imageView from the code. It's easy to apply animations on the images and to remove/add them after the animation begins.

Upvotes: 0

Bostone
Bostone

Reputation: 37154

All right - here's another way:

  1. Add ViewSwitcher with 2 ImageViews
  2. Since you can't use drag and drop library look for some alternatives but generally you want implement dragging the top image. Hopefully that will expose the hidden image but if not you will have to swap images when the drag starts
  3. Implement gesture performed listener to listen for the flick events on the top image
  4. When image is flicked away:

    a. Swap image views in ViewSwitcher (if not swapped already for the drag-n-drop)

    b. Pre-load next image into hidden ImageView

  5. Otherwise return top image into original location (don't load anything into hidden ImageView)

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007658

Use StackView, available on API Level 11 and higher.

Upvotes: 1

Bostone
Bostone

Reputation: 37154

Why not use a ViewPager and flip through your images from left to right? You can then utilize FragmentStatePagerAdapter to prefetch and cache your images as use flips through these

Upvotes: 0

Related Questions