hardartcore
hardartcore

Reputation: 17037

swipe images in android

I need a little information about how to do a swipe image viewer for Android.Something exactly like this : http://www.photoswipe.com/latest/examples/jquery-mobile.html#&ui-state=dialog .I'm have a listView and I want every time i click an listview item it opens a new windows with the selected image in fullscreen and when I tab on the image,the bottom part with the left right button shows up and some information above the image.In a fullscreen mode I want to be able to swipe left and right and different image shows up.

Any idea how to do this?Thanks a lot!

Upvotes: 1

Views: 1732

Answers (1)

Sherif elKhatib
Sherif elKhatib

Reputation: 45942

Insert imageviews inside a viewflipper (here is is called optionsVF)

In your onClick or something:

Animation in = AnimationFactory.inFromRight();
in.setDuration(500);
optionsVF.setInAnimation(in);
Animation   out = AnimationFactory.outToLeft();
out.setDuration(500);
optionsVF.setOutAnimation(out);
optionsVF.showNext();

my class :) AnimationFactory

/*
*  Copyright 2011 Sherif
*/

public class AnimationFactory {
    public static Animation inFromRight() {
    Animation inFromLeft = new TranslateAnimation(
    Animation.RELATIVE_TO_PARENT,  1.0f, Animation.RELATIVE_TO_PARENT,  0.0f,
    Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
    );
    inFromLeft.setDuration(500);
    inFromLeft.setInterpolator(new AccelerateInterpolator());
    return inFromLeft;
    }

    public static Animation outToLeft() {
    Animation inFromLeft = new TranslateAnimation(
    Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,  -1.0f,
    Animation.RELATIVE_TO_PARENT,  0.0f, Animation.RELATIVE_TO_PARENT,   0.0f
    );
    inFromLeft.setDuration(500);
    inFromLeft.setInterpolator(new AccelerateInterpolator());
    return inFromLeft;
    }
}

Upvotes: 2

Related Questions